Inv 歸檔改版
This commit is contained in:
parent
ce541f8df1
commit
1b0a2407b5
2
.gitignore
vendored
2
.gitignore
vendored
@ -344,3 +344,5 @@ healthchecksdb
|
||||
|
||||
/SolarPower/wwwroot/upload/operation_recode/1
|
||||
/SolarPower/wwwroot/upload/report/20210819
|
||||
/SolarPower/SolarPower.zip
|
||||
/SolarPower.zip
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
<configuration>
|
||||
|
||||
<connectionStrings>
|
||||
<add name="mySql" connectionString="server=60.251.164.103;user=webuser;Database=solar_master;Port=11306;password=FICadmin99;charset='utf8';pooling=true;sslmode=none;" providerName="MySql.Data.MySqlClient" />
|
||||
<add name="mySql" connectionString="server=60.251.164.103;user=webuser;Database=solar_master;Port=11306;password=FICadmin99;charset='utf8';pooling=true;sslmode=none;;Connection Timeout=6000" providerName="MySql.Data.MySqlClient" />
|
||||
<!--<add name="mySql" connectionString="server=localhost;user=root;Database=solar_master;Port=3306;password=zxcvb123;charset='utf8';pooling=true;sslmode=none;" providerName="MySql.Data.MySqlClient" />-->
|
||||
<!-- kai -->
|
||||
<!--<add name="mySql" connectionString="server=210.61.91.43;port=10068;user=idafenweb;Database=solar_power_test;Port=3306;password=P@ssw0rd;charset='utf8';pooling=true;sslmode=none;" providerName="MySql.Data.MySqlClient" />-->
|
||||
|
||||
@ -101,8 +101,11 @@ namespace solarApp.Service
|
||||
using (MySqlConnection conn = new MySqlConnection(Connection1))
|
||||
{
|
||||
conn.Open();
|
||||
//string sql = @"select DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d %H:%i') reportdate, inverterid, KWH, TODAYKWH, TOTALKWH, round(PR, 2) PR
|
||||
// from inverter_history_hour where left(`TIMESTAMP`, 10) = '" + reportDate + "' and inverterid = '" + invID + "' ";
|
||||
|
||||
string sql = @"select DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d %H:%i') reportdate, inverterid, KWH, TODAYKWH, TOTALKWH, round(PR, 2) PR
|
||||
from inverter_history_hour where left(`TIMESTAMP`, 10) = '" + reportDate + "' and inverterid = '" + invID + "' ";
|
||||
from inverter_history_hour where crdDate = '" + reportDate + "' and inverterid = '" + invID + "' ";
|
||||
List<web_inv_hour> ds = conn.Query<web_inv_hour>(sql).AsList<web_inv_hour>();
|
||||
conn.Close();
|
||||
return ds;
|
||||
@ -122,11 +125,11 @@ select DATE_FORMAT(a.`TIMESTAMP`,'%Y-%m-%d') reportdate, a.inverterid, round(a.K
|
||||
from inverter_history_day a left join (
|
||||
select DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') reportdate, inverterid, count(*) count
|
||||
from inverter_history_hour
|
||||
where left(`TIMESTAMP`, 10) between '" + date1 + "' and '" + date2 + @"' and inverterid = '" + invID + @"'
|
||||
where crdDate between '" + date1 + "' and '" + date2 + @"' and inverterid = '" + invID + @"'
|
||||
|
||||
group by DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d'), inverterid
|
||||
) b on a.inverterid = b.inverterid and DATE_FORMAT(a.`TIMESTAMP`,'%Y-%m-%d') = b.reportdate
|
||||
where left(a.`TIMESTAMP`, 10) between '" + date1 + "' and '" + date2 + "' and a.inverterid = '" + invID + "' order by 1";
|
||||
where crdDate between '" + date1 + "' and '" + date2 + "' and a.inverterid = '" + invID + "' order by 1";
|
||||
List<web_inv_hour> ds = conn.Query<web_inv_hour>(sql).AsList<web_inv_hour>();
|
||||
conn.Close();
|
||||
return ds;
|
||||
|
||||
@ -15,6 +15,7 @@ namespace solarApp.Service
|
||||
string Connection1 = string.Empty;
|
||||
ILogger _logger;
|
||||
|
||||
|
||||
public procInvSvc(string Connection_parame = null, ILogger logger = null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Connection_parame))
|
||||
@ -54,10 +55,15 @@ namespace solarApp.Service
|
||||
_logger.LogInformation("【ProcInvSvc】開始執行[{0}]在{1}逆變器清除資料表的資料", _siteID, _date1);
|
||||
}
|
||||
|
||||
//string sql = @"
|
||||
// delete from inverter_history_15min where powerstationID = @powerStationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1;
|
||||
// delete from inverter_history_hour where powerstationID = @powerStationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1;
|
||||
// delete from inverter_history_day where powerstationID = @powerStationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1;
|
||||
// delete from inverter_history_month where powerstationID = @powerStationID and left(`TIMESTAMP`, 7) = left(@date1, 7) ;";
|
||||
string sql = @"
|
||||
delete from inverter_history_15min where powerstationID = @powerStationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1;
|
||||
delete from inverter_history_hour where powerstationID = @powerStationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1;
|
||||
delete from inverter_history_day where powerstationID = @powerStationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1;
|
||||
delete from inverter_history_15min where powerstationID = @powerStationID and CrdDate = @date1;
|
||||
delete from inverter_history_hour where powerstationID = @powerStationID and CrdDate = @date1;
|
||||
delete from inverter_history_day where powerstationID = @powerStationID and CrdDate = @date1;
|
||||
delete from inverter_history_month where powerstationID = @powerStationID and left(`TIMESTAMP`, 7) = left(@date1, 7) ;";
|
||||
var ds = conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
|
||||
|
||||
@ -85,19 +91,21 @@ namespace solarApp.Service
|
||||
public bool archiveData(string siteID, string date1)
|
||||
{
|
||||
bool result = false;
|
||||
try
|
||||
{
|
||||
//try
|
||||
//{
|
||||
_siteID = siteID;
|
||||
_date1 = date1;
|
||||
get_siteInfo();
|
||||
clearData();
|
||||
insert_inv();
|
||||
//日報表
|
||||
//insert_report_invDay();
|
||||
result = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// throw ex;
|
||||
//}
|
||||
return result;
|
||||
}
|
||||
public bool get_siteInfo()
|
||||
@ -150,8 +158,8 @@ namespace solarApp.Service
|
||||
bool insert_inv()
|
||||
{
|
||||
bool result = false;
|
||||
try
|
||||
{
|
||||
//try
|
||||
//{
|
||||
using (MySqlConnection conn = new MySqlConnection(Connection1))
|
||||
{
|
||||
conn.Open();
|
||||
@ -168,34 +176,64 @@ namespace solarApp.Service
|
||||
}
|
||||
|
||||
sql = @"
|
||||
INSERT INTO solar_master.inverter_history_15min( PowerStationId, TIMESTAMP, INVERTERID, KWH, TODAYKWH, KWHKWP)
|
||||
select PowerStationId, reportdate, a.inverterid, KWH, TODAYKWH, (kwh/(capacity/4)) kwpkwp from
|
||||
(
|
||||
select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':00:00')reportdate, inverterid,
|
||||
INSERT INTO solar_master.inverter_history_15min( PowerStationId, TIMESTAMP, INVERTERID, KWH, TODAYKWH, KWHKWP)
|
||||
select PowerStationId, reportdate, a.inverterid, KWH, TODAYKWH, (kwh/(capacity/4)) kwpkwp from
|
||||
(
|
||||
select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':00:00')reportdate, inverterid,
|
||||
(sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
|
||||
from " + _siteDB + ".s" + _siteID01 + @"_inv
|
||||
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '00' and '10'
|
||||
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
|
||||
union
|
||||
select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':15:00')reportdate, inverterid,
|
||||
(sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
|
||||
from " + _siteDB + ".s" + _siteID01 + @"_inv
|
||||
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '15' and '25'
|
||||
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
|
||||
union
|
||||
select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':30:00')reportdate, inverterid,
|
||||
(sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
|
||||
from " + _siteDB + ".s" + _siteID01 + @"_inv
|
||||
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '30' and '40'
|
||||
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
|
||||
union
|
||||
select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':45:00')reportdate, inverterid,
|
||||
(sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
|
||||
from " + _siteDB + ".s" + _siteID01 + @"_inv
|
||||
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '00' and '10'
|
||||
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
|
||||
union
|
||||
select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':15:00')reportdate, inverterid,
|
||||
(sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
|
||||
from " + _siteDB + ".s" + _siteID01 + @"_inv
|
||||
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '15' and '25'
|
||||
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
|
||||
union
|
||||
select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':30:00')reportdate, inverterid,
|
||||
(sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
|
||||
from " + _siteDB + ".s" + _siteID01 + @"_inv
|
||||
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '30' and '40'
|
||||
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
|
||||
union
|
||||
select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':45:00')reportdate, inverterid,
|
||||
(sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
|
||||
from " + _siteDB + ".s" + _siteID01 + @"_inv
|
||||
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '45' and '55'
|
||||
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
|
||||
) a join " + _siteDB + @".inverter b on a.inverterid = b.inverterid";
|
||||
var ds = conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
|
||||
from " + _siteDB + ".s" + _siteID01 + @"_inv
|
||||
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '45' and '55'
|
||||
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
|
||||
) a join " + _siteDB + @".inverter b on a.inverterid = b.inverterid";
|
||||
|
||||
// sql = @"
|
||||
// INSERT INTO solar_master.inverter_history_15min( PowerStationId, TIMESTAMP, INVERTERID, KWH, TODAYKWH, KWHKWP)
|
||||
// select PowerStationId, reportdate, a.inverterid, KWH, TODAYKWH, (kwh/(capacity/4)) kwpkwp from
|
||||
// (
|
||||
//select @PowerStationId PowerStationId,CONCAT(left(CrdTime, 13), '%Y-%m-%d %H'), ':00:00')reportdate, inverterid,
|
||||
// (sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
|
||||
// from " + _siteDB + ".s" + _siteID01 + @"_inv
|
||||
// where left(CrdTime, 10) = @date1 and CONCAT(left(CrdTime, 13), '%Y-%m-%d %H:%i') , 2) between '00' and '10'
|
||||
// group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
|
||||
// union
|
||||
// select @PowerStationId PowerStationId, CONCAT(left(CrdTime, 13), ':15:00')reportdate, inverterid,
|
||||
// (sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
|
||||
// from " + _siteDB + ".s" + _siteID01 + @"_inv
|
||||
// where left(CrdTime, 10) = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '15' and '25'
|
||||
// group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
|
||||
// union
|
||||
// select @PowerStationId PowerStationId, CONCAT(left(CrdTime, 13), ':30:00')reportdate, inverterid,
|
||||
// (sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
|
||||
// from " + _siteDB + ".s" + _siteID01 + @"_inv
|
||||
// where left(CrdTime, 10) = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '30' and '40'
|
||||
// group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
|
||||
// union
|
||||
// select @PowerStationId PowerStationId, CONCAT(left(CrdTime, 13), ':45:00')reportdate, inverterid,
|
||||
// (sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
|
||||
// from " + _siteDB + ".s" + _siteID01 + @"_inv
|
||||
// where left(CrdTime, 10) = @date1 and MINUTE(CrdTime) between '45' and '55'
|
||||
// group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
|
||||
// ) a join " + _siteDB + @".inverter b on a.inverterid = b.inverterid";
|
||||
|
||||
var ds = conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
|
||||
|
||||
if (_logger != null)
|
||||
{
|
||||
@ -218,51 +256,101 @@ namespace solarApp.Service
|
||||
_logger.LogInformation("【ProcInvSvc】開始執行[{0}]在{1}逆變器hour補償", _siteID, _date1);
|
||||
}
|
||||
|
||||
sql = @"
|
||||
insert into solar_master.inverter_history_hour (PowerStationId, INVERTERID, TIMESTAMP, Irradiance, AC1V, AC1A, AC1W, AC1F, AC1WH, AC2V, AC2A, AC2W, AC2F, AC2WH,
|
||||
AC3V, AC3A, AC3W, AC3F, AC3WH, DC1V, DC1A, DC1W, DC1WH, DC2V, DC2A, DC2W, DC2WH, DC3V, DC3A, DC3W, DC3WH, DC4V, DC4A, DC4W, DC4WH, DC5V, DC5A, DC5W, DC5WH,
|
||||
PR, RA1, RA2, RA3, RA4, RA5, DCKW, ACKW, KWH, TODAYKWH, TOTALKWH, KWHKWP)
|
||||
//sql = @"
|
||||
// insert into solar_master.inverter_history_hour (PowerStationId, INVERTERID, TIMESTAMP, Irradiance, AC1V, AC1A, AC1W, AC1F, AC1WH, AC2V, AC2A, AC2W, AC2F, AC2WH,
|
||||
// AC3V, AC3A, AC3W, AC3F, AC3WH, DC1V, DC1A, DC1W, DC1WH, DC2V, DC2A, DC2W, DC2WH, DC3V, DC3A, DC3W, DC3WH, DC4V, DC4A, DC4W, DC4WH, DC5V, DC5A, DC5W, DC5WH,
|
||||
// PR, RA1, RA2, RA3, RA4, RA5, DCKW, ACKW, KWH, TODAYKWH, TOTALKWH, KWHKWP)
|
||||
|
||||
SELECT @powerstationID powerStationID, a.INVERTERID, a.reportDate, IFNULL(Irradiance, 0), 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,
|
||||
inv_pr.PR, a.RA1, a.RA2, a.RA3, a.RA4, a.RA5, ((DC1W + DC2W + DC3W + DC4W+ DC5W) / 1000) DCKW,
|
||||
((AC1W + AC2W + AC3W) / 1000) ACKW, a.KWH, a.TODAYKWH, a.TOTALKWH, (a.KWH / i.Capacity) AS KWHKWP
|
||||
from
|
||||
( -- 取得該時間區間的KWH
|
||||
SELECT concat(FROM_UNIXTIME(a.TIMESTAMP/1000,'%Y-%m-%d %H'), ':00:00') reportDate, a.INVERTERID,
|
||||
AVG(a.AC1V) AS AC1V, AVG(a.AC1A) AS AC1A, round(SUM(a.AC1W), 5) AS AC1W, AVG(a.AC1F) AS AC1F, SUM(a.AC1WH) AS AC1WH, AVG(a.AC2V) AS AC2V,
|
||||
AVG(a.AC2A) AS AC2A, round(SUM(a.AC2W), 5) AS AC2W, AVG(a.AC2F) AS AC2F, SUM(a.AC2WH) AS AC2WH,AVG(a.AC3V) AS AC3V, AVG(a.AC3A) AS AC3A,
|
||||
round(SUM(a.AC3W),5) AS AC3W, AVG(a.AC3F) AS AC3F, SUM(a.AC3WH) AS AC3WH, AVG(a.DC1V) AS DC1V, AVG(a.DC1A) AS DC1A, SUM(a.DC1W) AS DC1W,
|
||||
SUM(a.DC1WH) AS DC1WH, AVG(a.DC2V) AS DC2V, AVG(a.DC2A) AS DC2A, SUM(a.DC2W) AS DC2W, SUM(a.DC2WH) AS DC2WH, AVG(a.DC3V) AS DC3V,
|
||||
AVG(a.DC3A) AS DC3A, AVG(a.DC3W) AS DC3W, AVG(a.DC3WH) AS DC3WH, AVG(a.DC4V) AS DC4V, AVG(a.DC4A) AS DC4A, SUM(a.DC4W) AS DC4W,
|
||||
SUM(a.DC4WH) AS DC4WH,AVG(a.DC5V) AS DC5V, AVG(a.DC5A) AS DC5A, SUM(a.DC5W) AS DC5W, SUM(a.DC5WH) AS DC5WH,
|
||||
AVG(a.RA1) AS RA1, AVG(a.RA2) AS RA2, AVG(a.RA3) AS RA3,
|
||||
AVG(a.RA4) AS RA4, AVG(a.RA5) AS RA5, MAX(a.TODAYKWH) AS TODAYKWH, MAX(a.TOTALKWH) AS TOTALKWH, (SUM(a.WH)/1000) AS KWH
|
||||
FROM " + _siteDB + ".s" + _siteID01 + @"_inv a
|
||||
WHERE left(FROM_UNIXTIME(a.TIMESTAMP / 1000, '%Y-%m-%d'), 10) = @date1
|
||||
GROUP BY left(FROM_UNIXTIME(a.TIMESTAMP/ 1000, '%Y-%m-%d %H'), 13), a.INVERTERID
|
||||
) a
|
||||
LEFT JOIN( -- 取得整點值PR
|
||||
SELECT concat(FROM_UNIXTIME(inv.TIMESTAMP/1000,'%Y-%m-%d %H'), ':00:00') AS reportDate, inv.INVERTERID, inv.PR
|
||||
FROM " + _siteDB + ".s" + _siteID01 + @"_inv inv
|
||||
WHERE left(DATE_FORMAT(FROM_UNIXTIME(inv.TIMESTAMP / 1000), '%Y-%m-%d %H:%i'), 10) = @date1
|
||||
and right(DATE_FORMAT(FROM_UNIXTIME(inv.TIMESTAMP / 1000), '%Y-%m-%d %H:%i'), 2) = '55'
|
||||
GROUP BY FROM_UNIXTIME(inv.TIMESTAMP/ 1000, '%Y-%m-%d %H'), inv.INVERTERID
|
||||
) inv_pr
|
||||
ON a.reportDate = inv_pr.reportDate AND a.INVERTERID = inv_pr.INVERTERID
|
||||
-- 取得逆變器容量
|
||||
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
|
||||
from sensor_history_hour a
|
||||
where powerstationID = @powerstationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1
|
||||
)irr on a.reportDate = irr.reportDate
|
||||
order by a.INVERTERID, a.reportDate;";
|
||||
int ct = conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
|
||||
// SELECT @powerstationID powerStationID, a.INVERTERID, a.reportDate, IFNULL(Irradiance, 0), 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,
|
||||
// inv_pr.PR, a.RA1, a.RA2, a.RA3, a.RA4, a.RA5, ((DC1W + DC2W + DC3W + DC4W+ DC5W) / 1000) DCKW,
|
||||
// ((AC1W + AC2W + AC3W) / 1000) ACKW, a.KWH, a.TODAYKWH, a.TOTALKWH, (a.KWH / i.Capacity) AS KWHKWP
|
||||
// from
|
||||
// ( -- 取得該時間區間的KWH
|
||||
// SELECT concat(FROM_UNIXTIME(a.TIMESTAMP/1000,'%Y-%m-%d %H'), ':00:00') reportDate, a.INVERTERID,
|
||||
// AVG(a.AC1V) AS AC1V, AVG(a.AC1A) AS AC1A, round(SUM(a.AC1W), 5) AS AC1W, AVG(a.AC1F) AS AC1F, SUM(a.AC1WH) AS AC1WH, AVG(a.AC2V) AS AC2V,
|
||||
// AVG(a.AC2A) AS AC2A, round(SUM(a.AC2W), 5) AS AC2W, AVG(a.AC2F) AS AC2F, SUM(a.AC2WH) AS AC2WH,AVG(a.AC3V) AS AC3V, AVG(a.AC3A) AS AC3A,
|
||||
// round(SUM(a.AC3W),5) AS AC3W, AVG(a.AC3F) AS AC3F, SUM(a.AC3WH) AS AC3WH, AVG(a.DC1V) AS DC1V, AVG(a.DC1A) AS DC1A, SUM(a.DC1W) AS DC1W,
|
||||
// SUM(a.DC1WH) AS DC1WH, AVG(a.DC2V) AS DC2V, AVG(a.DC2A) AS DC2A, SUM(a.DC2W) AS DC2W, SUM(a.DC2WH) AS DC2WH, AVG(a.DC3V) AS DC3V,
|
||||
// AVG(a.DC3A) AS DC3A, AVG(a.DC3W) AS DC3W, AVG(a.DC3WH) AS DC3WH, AVG(a.DC4V) AS DC4V, AVG(a.DC4A) AS DC4A, SUM(a.DC4W) AS DC4W,
|
||||
// SUM(a.DC4WH) AS DC4WH,AVG(a.DC5V) AS DC5V, AVG(a.DC5A) AS DC5A, SUM(a.DC5W) AS DC5W, SUM(a.DC5WH) AS DC5WH,
|
||||
// AVG(a.RA1) AS RA1, AVG(a.RA2) AS RA2, AVG(a.RA3) AS RA3,
|
||||
// AVG(a.RA4) AS RA4, AVG(a.RA5) AS RA5, MAX(a.TODAYKWH) AS TODAYKWH, MAX(a.TOTALKWH) AS TOTALKWH, (SUM(a.WH)/1000) AS KWH
|
||||
// FROM " + _siteDB + ".s" + _siteID01 + @"_inv a
|
||||
// WHERE left(FROM_UNIXTIME(a.TIMESTAMP / 1000, '%Y-%m-%d'), 10) = @date1
|
||||
// GROUP BY left(FROM_UNIXTIME(a.TIMESTAMP/ 1000, '%Y-%m-%d %H'), 13), a.INVERTERID
|
||||
// ) a
|
||||
// LEFT JOIN( -- 取得整點值PR
|
||||
// SELECT concat(FROM_UNIXTIME(inv.TIMESTAMP/1000,'%Y-%m-%d %H'), ':00:00') AS reportDate, inv.INVERTERID, inv.PR
|
||||
// FROM " + _siteDB + ".s" + _siteID01 + @"_inv inv
|
||||
// WHERE left(DATE_FORMAT(FROM_UNIXTIME(inv.TIMESTAMP / 1000), '%Y-%m-%d %H:%i'), 10) = @date1
|
||||
// and right(DATE_FORMAT(FROM_UNIXTIME(inv.TIMESTAMP / 1000), '%Y-%m-%d %H:%i'), 2) = '55'
|
||||
// GROUP BY FROM_UNIXTIME(inv.TIMESTAMP/ 1000, '%Y-%m-%d %H'), inv.INVERTERID
|
||||
// ) inv_pr
|
||||
// ON a.reportDate = inv_pr.reportDate AND a.INVERTERID = inv_pr.INVERTERID
|
||||
// -- 取得逆變器容量
|
||||
// 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
|
||||
// from sensor_history_hour a
|
||||
// where powerstationID = @powerstationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1
|
||||
// )irr on a.reportDate = irr.reportDate
|
||||
// order by a.INVERTERID, a.reportDate;";
|
||||
//int ct = conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
|
||||
|
||||
if (_logger != null)
|
||||
sql = @$"DROP TEMPORARY TABLE IF EXISTS Inv_day_"+ _powerStationID + @"_s1;
|
||||
CREATE TEMPORARY TABLE Inv_day_" + _powerStationID + @"_s1
|
||||
select * from " + _siteDB + ".s" + _siteID01 + @"_inv a
|
||||
WHERE left(crdTime, 10) = @date1;
|
||||
# 2. add index
|
||||
ALTER TABLE Inv_day_" + _powerStationID + @"_s1 ADD INDEX `temp_index` (crdTime, inverterid);";
|
||||
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 + @" 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, 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 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
|
||||
from sensor_history_hour
|
||||
where powerstationID = " + _powerStationID + @" and DATE_FORMAT(`TIMESTAMP`, '%Y-%m-%d') = @date1
|
||||
)irr on a.reportDate = irr.reportDate; ";
|
||||
ct = conn.Execute(sql, new { date1 = _date1 });
|
||||
//# 3. insert ans
|
||||
sql = @$"
|
||||
INSERT INTO solar_master.inverter_history_hour(`powerStationID`, `INVERTERID`, `TIMESTAMP`, `AC1V`, `AC1A`, `AC1W`, `AC1F`, `AC1WH`, `AC2V`, `AC2A`, `AC2W`, `AC2F`, `AC2WH`, `AC3V`, `AC3A`, `AC3W`, `AC3F`, `AC3WH`, `DC1V`, `DC1A`, `DC1W`, `DC1WH`, `DC2V`, `DC2A`, `DC2W`, `DC2WH`, `DC3V`, `DC3A`, `DC3W`, `DC3WH`, `DC4V`, `DC4A`, `DC4W`, `DC4WH`, `DC5V`, `DC5A`, `DC5W`, `DC5WH`, `RA1`, `RA2`, `RA3`, `RA4`, `RA5`, `KWH`, `TODAYKWH`, `TOTALKWH`, `Irradiance`, `PR`, `DCKW`, `ACKW`, `KWHKWP`)
|
||||
select `powerStationID`, a.`INVERTERID`, a.`reportDate`, `AC1V`, `AC1A`, `AC1W`, `AC1F`, `AC1WH`, `AC2V`, `AC2A`, `AC2W`, `AC2F`, `AC2WH`, `AC3V`, `AC3A`, `AC3W`, `AC3F`, `AC3WH`, `DC1V`, `DC1A`, `DC1W`, `DC1WH`, `DC2V`, `DC2A`, `DC2W`, `DC2WH`, `DC3V`, `DC3A`, `DC3W`, `DC3WH`, `DC4V`, `DC4A`, `DC4W`, `DC4WH`, `DC5V`, `DC5A`, `DC5W`, `DC5WH`, `RA1`, `RA2`, `RA3`, `RA4`, `RA5`, `KWH`, `TODAYKWH`, `TOTALKWH`, `irr`, inv_pr.`PR`, `DCKW`, `ACKW`, `KWHKWP`
|
||||
from Inv_day_" + _powerStationID + @"_s2 a left JOIN( -- 取得整點值PR
|
||||
SELECT concat(left(crdTime, 13), ':00:00') AS reportDate, inv.INVERTERID, inv.PR
|
||||
FROM Inv_day_" + _powerStationID + @"_s1 inv
|
||||
WHERE minute(crdtime) = '55'
|
||||
GROUP BY left(crdTime, 13), inv.INVERTERID
|
||||
) inv_pr
|
||||
ON a.reportDate = inv_pr.reportDate AND a.INVERTERID = inv_pr.INVERTERID;";
|
||||
ct = conn.Execute(sql, new { date1 = _date1 });
|
||||
if (_logger != null)
|
||||
{
|
||||
_logger.LogInformation("【ProcInvSvc】執行完成[{0}]在{1}逆變器hour補償", _siteID, _date1);
|
||||
}
|
||||
@ -387,6 +475,95 @@ namespace solarApp.Service
|
||||
|
||||
#endregion month
|
||||
|
||||
conn.Close();
|
||||
}
|
||||
result = true;
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// throw ex;
|
||||
//}
|
||||
return result;
|
||||
}
|
||||
|
||||
void ck_empty_archivedData(string siteID, string date1)
|
||||
{
|
||||
_siteID = siteID;
|
||||
_date1 = date1;
|
||||
get_siteInfo();
|
||||
}
|
||||
|
||||
//建立日報表
|
||||
bool insert_report_invDay() {
|
||||
bool result = false;
|
||||
try
|
||||
{
|
||||
using (MySqlConnection conn = new MySqlConnection(Connection1))
|
||||
{
|
||||
conn.Open();
|
||||
string ss = @"SET SESSION sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY,',''));";
|
||||
conn.Execute(ss);
|
||||
|
||||
string sql = string.Empty;
|
||||
#region get SQL
|
||||
try
|
||||
{
|
||||
if (_logger != null)
|
||||
{
|
||||
_logger.LogInformation("【Proc_inv_日報 】開始執行[{0}]在{1}inv_get_SQLStatement", _siteID, _date1);
|
||||
}
|
||||
|
||||
#region 取得 inv 數量
|
||||
sql = $@"select * from v_company_inv where ";
|
||||
#endregion
|
||||
|
||||
sql = @$"
|
||||
SET @sql = NULL;
|
||||
SELECT
|
||||
GROUP_CONCAT(DISTINCT
|
||||
CONCAT('max(case when INVERTERID = ''', INVERTERID, ''' then a.KWH end) ''inv_', right(INVERTERID, 2), '''')
|
||||
) INTO @sql
|
||||
FROM inverter_history_hour where powerstationId = {_powerStationID} and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = '{_date1}';
|
||||
SET @sql = CONCAT('SELECT DATE_FORMAT(a.TIMESTAMP,''%m-%d %H'') report_date, ', @sql,
|
||||
', b.KWH hourKWH,
|
||||
ifnull(round((b.KWH / (SELECT MAX(TODAYKWH) FROM power_station_history_hour
|
||||
WHERE DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') = ''{_date1}'' and powerstationid = {_powerStationID}))*100,2)
|
||||
, 0) ''hourKWHp'', ifnull(d.irradiance, 0) ''irradiance'', ifnull(d.Temperature, 0) ''temperature'',
|
||||
ifnull(b.money, 0) ''hourmoney'', ifnull(round(b.PR, 2), 0) as pr
|
||||
FROM inverter_history_hour a left join
|
||||
( # 每小時加總 inv
|
||||
select powerStationid, DATE_FORMAT(TIMESTAMP,''%Y-%m-%d %H:%i'') report_date, siteid, sitetype, round(KWH, 2) KWH,
|
||||
round(TODAYKWH, 2) TODAYKWH,round(KWHKWP, 2) KWHKWP, round(PR, 2) PR, round(money, 2) money
|
||||
from power_station_history_hour
|
||||
where powerstationid = {_powerStationID} and DATE_FORMAT(`TIMESTAMP`,''%Y-%m-%d'') = ''{_date1}''
|
||||
) b on a.powerStationid = b.powerStationid and concat(a.crdDate,' ', left(a.crdTime, 5)) = b.report_date
|
||||
|
||||
left join
|
||||
(
|
||||
select powerStationID, DATE_FORMAT(TIMESTAMP,''%Y-%m-%d %H:00'')report_date, irradiance, Temperature
|
||||
from sensor_history_hour
|
||||
where powerstationid = {_powerStationID} and DATE_FORMAT(`TIMESTAMP`,''%Y-%m-%d'') = ''{_date1}''
|
||||
) d on a.powerStationid = d.powerStationid and concat(a.crdDate,' ', left(a.crdTime, 2), '':00'') = d.report_date
|
||||
where a.crdDate = ''{_date1}''
|
||||
GROUP BY concat(a.crdDate,' ', left(a.crdTime, 2))
|
||||
order by a.crdTime ');
|
||||
select @sql as 'mySelect'; #顯示動態語法";
|
||||
var ds = conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
|
||||
|
||||
if (_logger != null)
|
||||
{
|
||||
_logger.LogInformation("【Proc_inv_日報】執行完成[{0}]在{1} inv_get_SQLStatement", _siteID, _date1);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError("【Proc_inv_日報】執行失敗[{0}]在{1}inv_get_SQLStatement", _siteID, _date1);
|
||||
_logger.LogError("【Proc_inv_日報】執行失敗[{0}]在{1}inv_get_SQLStatement - [Exception]:{2}", _siteID, _date1, ex.ToString());
|
||||
throw ex;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
conn.Close();
|
||||
}
|
||||
result = true;
|
||||
|
||||
248
solarApp/fmArchive.Designer.cs
generated
248
solarApp/fmArchive.Designer.cs
generated
@ -32,6 +32,7 @@ namespace solarApp
|
||||
this.tabControl1 = new System.Windows.Forms.TabControl();
|
||||
this.tabPage1 = new System.Windows.Forms.TabPage();
|
||||
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
||||
this.bt_rpt_invDay = new System.Windows.Forms.Button();
|
||||
this.bt_meter = new System.Windows.Forms.Button();
|
||||
this.lbmsg = new System.Windows.Forms.Label();
|
||||
this.dtSelect2 = new System.Windows.Forms.DateTimePicker();
|
||||
@ -44,21 +45,41 @@ namespace solarApp
|
||||
this.bt_site = new System.Windows.Forms.Button();
|
||||
this.bt_Inv = new System.Windows.Forms.Button();
|
||||
this.bt_Sensor = new System.Windows.Forms.Button();
|
||||
this.dataGridView1 = new System.Windows.Forms.DataGridView();
|
||||
this.br_rpt_invDay = new System.Windows.Forms.DataGridView();
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.btVerifyData = new System.Windows.Forms.Button();
|
||||
this.lbSiteDB_sensor = new System.Windows.Forms.Label();
|
||||
this.lbSiteID_sensor = new System.Windows.Forms.Label();
|
||||
this.lbSiteName_sensor = new System.Windows.Forms.Label();
|
||||
this.tabPage2 = new System.Windows.Forms.TabPage();
|
||||
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
|
||||
this.button3 = new System.Windows.Forms.Button();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
|
||||
this.button2 = new System.Windows.Forms.Button();
|
||||
this.flowLayoutPanel2 = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.dateTimePicker2 = new System.Windows.Forms.DateTimePicker();
|
||||
this.dataGridView2 = new System.Windows.Forms.DataGridView();
|
||||
this.panel2 = new System.Windows.Forms.Panel();
|
||||
this.button9 = new System.Windows.Forms.Button();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.tabControl1.SuspendLayout();
|
||||
this.tabPage1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
|
||||
this.splitContainer1.Panel1.SuspendLayout();
|
||||
this.splitContainer1.Panel2.SuspendLayout();
|
||||
this.splitContainer1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.br_rpt_invDay)).BeginInit();
|
||||
this.panel1.SuspendLayout();
|
||||
this.tabPage2.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
|
||||
this.splitContainer2.Panel1.SuspendLayout();
|
||||
this.splitContainer2.Panel2.SuspendLayout();
|
||||
this.splitContainer2.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit();
|
||||
this.panel2.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// tabControl1
|
||||
@ -78,7 +99,7 @@ namespace solarApp
|
||||
this.tabPage1.Controls.Add(this.splitContainer1);
|
||||
this.tabPage1.Location = new System.Drawing.Point(4, 31);
|
||||
this.tabPage1.Name = "tabPage1";
|
||||
this.tabPage1.Padding = new System.Windows.Forms.Padding(3, 3, 3, 3);
|
||||
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage1.Size = new System.Drawing.Size(1774, 918);
|
||||
this.tabPage1.TabIndex = 0;
|
||||
this.tabPage1.Text = "tabPage1";
|
||||
@ -93,6 +114,7 @@ namespace solarApp
|
||||
// splitContainer1.Panel1
|
||||
//
|
||||
this.splitContainer1.Panel1.BackColor = System.Drawing.SystemColors.ActiveCaption;
|
||||
this.splitContainer1.Panel1.Controls.Add(this.bt_rpt_invDay);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.bt_meter);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.lbmsg);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.dtSelect2);
|
||||
@ -108,17 +130,28 @@ namespace solarApp
|
||||
//
|
||||
// splitContainer1.Panel2
|
||||
//
|
||||
this.splitContainer1.Panel2.Controls.Add(this.dataGridView1);
|
||||
this.splitContainer1.Panel2.Controls.Add(this.br_rpt_invDay);
|
||||
this.splitContainer1.Panel2.Controls.Add(this.panel1);
|
||||
this.splitContainer1.Size = new System.Drawing.Size(1768, 912);
|
||||
this.splitContainer1.SplitterDistance = 299;
|
||||
this.splitContainer1.SplitterDistance = 400;
|
||||
this.splitContainer1.SplitterWidth = 10;
|
||||
this.splitContainer1.TabIndex = 0;
|
||||
//
|
||||
// bt_rpt_invDay
|
||||
//
|
||||
this.bt_rpt_invDay.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.bt_rpt_invDay.Location = new System.Drawing.Point(223, 790);
|
||||
this.bt_rpt_invDay.Name = "bt_rpt_invDay";
|
||||
this.bt_rpt_invDay.Size = new System.Drawing.Size(135, 44);
|
||||
this.bt_rpt_invDay.TabIndex = 12;
|
||||
this.bt_rpt_invDay.Text = "日報表";
|
||||
this.bt_rpt_invDay.UseVisualStyleBackColor = true;
|
||||
this.bt_rpt_invDay.Click += new System.EventHandler(this.bt_rpt_invDay_Click);
|
||||
//
|
||||
// bt_meter
|
||||
//
|
||||
this.bt_meter.Location = new System.Drawing.Point(156, 786);
|
||||
this.bt_meter.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.bt_meter.Location = new System.Drawing.Point(10, 786);
|
||||
this.bt_meter.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.bt_meter.Name = "bt_meter";
|
||||
this.bt_meter.Size = new System.Drawing.Size(135, 56);
|
||||
this.bt_meter.TabIndex = 11;
|
||||
@ -159,7 +192,7 @@ namespace solarApp
|
||||
this.bt_clear_sensor.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.bt_clear_sensor.Location = new System.Drawing.Point(10, 635);
|
||||
this.bt_clear_sensor.Name = "bt_clear_sensor";
|
||||
this.bt_clear_sensor.Size = new System.Drawing.Size(135, 44);
|
||||
this.bt_clear_sensor.Size = new System.Drawing.Size(119, 44);
|
||||
this.bt_clear_sensor.TabIndex = 7;
|
||||
this.bt_clear_sensor.Text = "clear data";
|
||||
this.bt_clear_sensor.UseVisualStyleBackColor = true;
|
||||
@ -171,7 +204,7 @@ namespace solarApp
|
||||
this.bt_clear_station.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.bt_clear_station.Location = new System.Drawing.Point(10, 735);
|
||||
this.bt_clear_station.Name = "bt_clear_station";
|
||||
this.bt_clear_station.Size = new System.Drawing.Size(135, 44);
|
||||
this.bt_clear_station.Size = new System.Drawing.Size(119, 44);
|
||||
this.bt_clear_station.TabIndex = 6;
|
||||
this.bt_clear_station.Text = "clear data";
|
||||
this.bt_clear_station.UseVisualStyleBackColor = true;
|
||||
@ -183,7 +216,7 @@ namespace solarApp
|
||||
this.bt_clear_inv.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.bt_clear_inv.Location = new System.Drawing.Point(10, 686);
|
||||
this.bt_clear_inv.Name = "bt_clear_inv";
|
||||
this.bt_clear_inv.Size = new System.Drawing.Size(135, 44);
|
||||
this.bt_clear_inv.Size = new System.Drawing.Size(119, 44);
|
||||
this.bt_clear_inv.TabIndex = 5;
|
||||
this.bt_clear_inv.Text = "clear data";
|
||||
this.bt_clear_inv.UseVisualStyleBackColor = true;
|
||||
@ -194,7 +227,7 @@ namespace solarApp
|
||||
this.fp_site.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.fp_site.Location = new System.Drawing.Point(0, 0);
|
||||
this.fp_site.Name = "fp_site";
|
||||
this.fp_site.Size = new System.Drawing.Size(299, 530);
|
||||
this.fp_site.Size = new System.Drawing.Size(400, 530);
|
||||
this.fp_site.TabIndex = 4;
|
||||
//
|
||||
// dtSelect1
|
||||
@ -238,16 +271,16 @@ namespace solarApp
|
||||
this.bt_Sensor.UseVisualStyleBackColor = true;
|
||||
this.bt_Sensor.Click += new System.EventHandler(this.bt_Sensor_Click);
|
||||
//
|
||||
// dataGridView1
|
||||
// br_rpt_invDay
|
||||
//
|
||||
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.dataGridView1.Location = new System.Drawing.Point(0, 125);
|
||||
this.dataGridView1.Name = "dataGridView1";
|
||||
this.dataGridView1.RowHeadersWidth = 51;
|
||||
this.dataGridView1.RowTemplate.Height = 29;
|
||||
this.dataGridView1.Size = new System.Drawing.Size(1459, 787);
|
||||
this.dataGridView1.TabIndex = 1;
|
||||
this.br_rpt_invDay.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.br_rpt_invDay.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.br_rpt_invDay.Location = new System.Drawing.Point(0, 125);
|
||||
this.br_rpt_invDay.Name = "br_rpt_invDay";
|
||||
this.br_rpt_invDay.RowHeadersWidth = 51;
|
||||
this.br_rpt_invDay.RowTemplate.Height = 29;
|
||||
this.br_rpt_invDay.Size = new System.Drawing.Size(1358, 787);
|
||||
this.br_rpt_invDay.TabIndex = 1;
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
@ -259,7 +292,7 @@ namespace solarApp
|
||||
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.panel1.Location = new System.Drawing.Point(0, 0);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Size = new System.Drawing.Size(1459, 125);
|
||||
this.panel1.Size = new System.Drawing.Size(1358, 125);
|
||||
this.panel1.TabIndex = 0;
|
||||
//
|
||||
// btVerifyData
|
||||
@ -309,14 +342,158 @@ namespace solarApp
|
||||
//
|
||||
// tabPage2
|
||||
//
|
||||
this.tabPage2.Controls.Add(this.splitContainer2);
|
||||
this.tabPage2.Location = new System.Drawing.Point(4, 31);
|
||||
this.tabPage2.Name = "tabPage2";
|
||||
this.tabPage2.Padding = new System.Windows.Forms.Padding(3, 3, 3, 3);
|
||||
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage2.Size = new System.Drawing.Size(1774, 918);
|
||||
this.tabPage2.TabIndex = 1;
|
||||
this.tabPage2.Text = "tabPage2";
|
||||
this.tabPage2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// splitContainer2
|
||||
//
|
||||
this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.splitContainer2.Location = new System.Drawing.Point(3, 3);
|
||||
this.splitContainer2.Name = "splitContainer2";
|
||||
//
|
||||
// splitContainer2.Panel1
|
||||
//
|
||||
this.splitContainer2.Panel1.BackColor = System.Drawing.Color.OldLace;
|
||||
this.splitContainer2.Panel1.Controls.Add(this.button3);
|
||||
this.splitContainer2.Panel1.Controls.Add(this.label1);
|
||||
this.splitContainer2.Panel1.Controls.Add(this.dateTimePicker1);
|
||||
this.splitContainer2.Panel1.Controls.Add(this.button2);
|
||||
this.splitContainer2.Panel1.Controls.Add(this.flowLayoutPanel2);
|
||||
this.splitContainer2.Panel1.Controls.Add(this.dateTimePicker2);
|
||||
//
|
||||
// splitContainer2.Panel2
|
||||
//
|
||||
this.splitContainer2.Panel2.Controls.Add(this.dataGridView2);
|
||||
this.splitContainer2.Panel2.Controls.Add(this.panel2);
|
||||
this.splitContainer2.Size = new System.Drawing.Size(1768, 912);
|
||||
this.splitContainer2.SplitterDistance = 299;
|
||||
this.splitContainer2.SplitterWidth = 10;
|
||||
this.splitContainer2.TabIndex = 1;
|
||||
//
|
||||
// button3
|
||||
//
|
||||
this.button3.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.button3.Location = new System.Drawing.Point(10, 640);
|
||||
this.button3.Name = "button3";
|
||||
this.button3.Size = new System.Drawing.Size(135, 44);
|
||||
this.button3.TabIndex = 12;
|
||||
this.button3.Text = "Sensor 歸檔";
|
||||
this.button3.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(10, 569);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(20, 19);
|
||||
this.label1.TabIndex = 10;
|
||||
this.label1.Text = "~";
|
||||
//
|
||||
// dateTimePicker1
|
||||
//
|
||||
this.dateTimePicker1.Location = new System.Drawing.Point(10, 593);
|
||||
this.dateTimePicker1.Name = "dateTimePicker1";
|
||||
this.dateTimePicker1.Size = new System.Drawing.Size(145, 27);
|
||||
this.dateTimePicker1.TabIndex = 9;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
this.button2.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.button2.Location = new System.Drawing.Point(9, 846);
|
||||
this.button2.Name = "button2";
|
||||
this.button2.Size = new System.Drawing.Size(282, 61);
|
||||
this.button2.TabIndex = 8;
|
||||
this.button2.Text = "單日歸檔";
|
||||
this.button2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// flowLayoutPanel2
|
||||
//
|
||||
this.flowLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.flowLayoutPanel2.Location = new System.Drawing.Point(0, 0);
|
||||
this.flowLayoutPanel2.Name = "flowLayoutPanel2";
|
||||
this.flowLayoutPanel2.Size = new System.Drawing.Size(299, 530);
|
||||
this.flowLayoutPanel2.TabIndex = 4;
|
||||
//
|
||||
// dateTimePicker2
|
||||
//
|
||||
this.dateTimePicker2.Location = new System.Drawing.Point(10, 536);
|
||||
this.dateTimePicker2.Name = "dateTimePicker2";
|
||||
this.dateTimePicker2.Size = new System.Drawing.Size(145, 27);
|
||||
this.dateTimePicker2.TabIndex = 3;
|
||||
//
|
||||
// dataGridView2
|
||||
//
|
||||
this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.dataGridView2.Location = new System.Drawing.Point(0, 125);
|
||||
this.dataGridView2.Name = "dataGridView2";
|
||||
this.dataGridView2.RowHeadersWidth = 51;
|
||||
this.dataGridView2.RowTemplate.Height = 29;
|
||||
this.dataGridView2.Size = new System.Drawing.Size(1459, 787);
|
||||
this.dataGridView2.TabIndex = 1;
|
||||
//
|
||||
// panel2
|
||||
//
|
||||
this.panel2.BackColor = System.Drawing.Color.Moccasin;
|
||||
this.panel2.Controls.Add(this.button9);
|
||||
this.panel2.Controls.Add(this.label2);
|
||||
this.panel2.Controls.Add(this.label3);
|
||||
this.panel2.Controls.Add(this.label4);
|
||||
this.panel2.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.panel2.Location = new System.Drawing.Point(0, 0);
|
||||
this.panel2.Name = "panel2";
|
||||
this.panel2.Size = new System.Drawing.Size(1459, 125);
|
||||
this.panel2.TabIndex = 0;
|
||||
//
|
||||
// button9
|
||||
//
|
||||
this.button9.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.button9.Location = new System.Drawing.Point(635, 8);
|
||||
this.button9.Name = "button9";
|
||||
this.button9.Size = new System.Drawing.Size(158, 44);
|
||||
this.button9.TabIndex = 12;
|
||||
this.button9.Text = "檢核結果";
|
||||
this.button9.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Font = new System.Drawing.Font("Microsoft JhengHei UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.label2.Location = new System.Drawing.Point(49, 19);
|
||||
this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(79, 24);
|
||||
this.label2.TabIndex = 11;
|
||||
this.label2.Text = "Site_DB";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Font = new System.Drawing.Font("Microsoft JhengHei UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.label3.Location = new System.Drawing.Point(201, 19);
|
||||
this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(72, 24);
|
||||
this.label3.TabIndex = 10;
|
||||
this.label3.Text = "Site_ID";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Font = new System.Drawing.Font("Microsoft JhengHei UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.label4.Location = new System.Drawing.Point(360, 19);
|
||||
this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(107, 24);
|
||||
this.label4.TabIndex = 9;
|
||||
this.label4.Text = "Site_Name";
|
||||
//
|
||||
// fmArchive
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 19F);
|
||||
@ -333,9 +510,18 @@ namespace solarApp
|
||||
this.splitContainer1.Panel2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
|
||||
this.splitContainer1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.br_rpt_invDay)).EndInit();
|
||||
this.panel1.ResumeLayout(false);
|
||||
this.panel1.PerformLayout();
|
||||
this.tabPage2.ResumeLayout(false);
|
||||
this.splitContainer2.Panel1.ResumeLayout(false);
|
||||
this.splitContainer2.Panel1.PerformLayout();
|
||||
this.splitContainer2.Panel2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();
|
||||
this.splitContainer2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit();
|
||||
this.panel2.ResumeLayout(false);
|
||||
this.panel2.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
@ -345,7 +531,7 @@ namespace solarApp
|
||||
private System.Windows.Forms.TabControl tabControl1;
|
||||
private System.Windows.Forms.TabPage tabPage1;
|
||||
private System.Windows.Forms.SplitContainer splitContainer1;
|
||||
private System.Windows.Forms.DataGridView dataGridView1;
|
||||
private System.Windows.Forms.DataGridView br_rpt_invDay;
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
private System.Windows.Forms.TabPage tabPage2;
|
||||
private System.Windows.Forms.DateTimePicker dtSelect1;
|
||||
@ -365,5 +551,19 @@ namespace solarApp
|
||||
private System.Windows.Forms.Label lbmsg;
|
||||
private System.Windows.Forms.DateTimePicker dtSelect2;
|
||||
private System.Windows.Forms.Button bt_meter;
|
||||
private System.Windows.Forms.Button bt_rpt_invDay;
|
||||
private System.Windows.Forms.SplitContainer splitContainer2;
|
||||
private System.Windows.Forms.Button button3;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.DateTimePicker dateTimePicker1;
|
||||
private System.Windows.Forms.Button button2;
|
||||
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel2;
|
||||
private System.Windows.Forms.DateTimePicker dateTimePicker2;
|
||||
private System.Windows.Forms.DataGridView dataGridView2;
|
||||
private System.Windows.Forms.Panel panel2;
|
||||
private System.Windows.Forms.Button button9;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.Label label4;
|
||||
}
|
||||
}
|
||||
@ -82,9 +82,17 @@ namespace solarApp
|
||||
fm.Show();
|
||||
}
|
||||
|
||||
public IEnumerable<DateTime> EachDay(DateTime from, DateTime thru)
|
||||
{
|
||||
for (var day = from.Date; day.Date <= thru.Date; day = day.AddDays(1))
|
||||
yield return day;
|
||||
}
|
||||
|
||||
|
||||
private void bt_Inv_Click(object sender, EventArgs e)
|
||||
{
|
||||
string date1 = dtSelect1.Value.ToString("yyyy-MM-dd");
|
||||
string date2 = dtSelect2.Value.ToString("yyyy-MM-dd");
|
||||
//procSensorSvc sensorSvc = new procSensorSvc(lbSiteDB_sensor.Text, lbSiteID_sensor.Text, date1, date1);
|
||||
procInvSvc invSvc = new procInvSvc();
|
||||
//invSvc._siteDB = lbSiteDB_sensor.Text;
|
||||
@ -92,7 +100,11 @@ namespace solarApp
|
||||
//invSvc._siteID01 = lbSiteID_sensor.Text;
|
||||
//invSvc._date1 = date1;
|
||||
//invSvc._date2 = date1;
|
||||
invSvc.archiveData(lbSiteID_sensor.Text.Substring(0, 9), date1);
|
||||
foreach (DateTime day in EachDay(DateTime.Parse(date1), DateTime.Parse(date2)))
|
||||
{
|
||||
//string d1 = day.ToString("yyyy-MM-dd");
|
||||
invSvc.archiveData(lbSiteID_sensor.Text.Substring(0, 9), day.ToString("yyyy-MM-dd"));
|
||||
}
|
||||
//sensorSvc.archiveData();
|
||||
MessageBox.Show("OK");
|
||||
}
|
||||
@ -188,5 +200,20 @@ namespace solarApp
|
||||
sensorSvc.archiveMeterData(lbSiteID_sensor.Text.Substring(0, 9), date1);
|
||||
MessageBox.Show("OK");
|
||||
}
|
||||
|
||||
private void bt_rpt_invDay_Click(object sender, EventArgs e)
|
||||
{
|
||||
string date1 = dtSelect1.Value.ToString("yyyy-MM-dd");
|
||||
//procSensorSvc sensorSvc = new procSensorSvc(lbSiteDB_sensor.Text, lbSiteID_sensor.Text, date1, date1);
|
||||
procInvSvc invSvc = new procInvSvc();
|
||||
//invSvc._siteDB = lbSiteDB_sensor.Text;
|
||||
//invSvc._siteID = lbSiteID_sensor.Text.Substring(0, 9);
|
||||
//invSvc._siteID01 = lbSiteID_sensor.Text;
|
||||
//invSvc._date1 = date1;
|
||||
//invSvc._date2 = date1;
|
||||
invSvc.archiveData(lbSiteID_sensor.Text.Substring(0, 9), date1);
|
||||
//sensorSvc.archiveData();
|
||||
MessageBox.Show("OK");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user