日報表快取 OK
This commit is contained in:
parent
42ea0d476c
commit
c1e3f106a2
@ -154,4 +154,129 @@ namespace solarApp.Model
|
|||||||
public double todaykWh { get; set; }
|
public double todaykWh { get; set; }
|
||||||
public double pr { get; set; }
|
public double pr { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class station_inv_list
|
||||||
|
{
|
||||||
|
public int PowerStationId { get; set; }
|
||||||
|
public string station_name { get; set; }
|
||||||
|
public string inverterid { get; set; }
|
||||||
|
public string station_code { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class report_inv_resualt
|
||||||
|
{
|
||||||
|
public string report_date { get; set; }
|
||||||
|
public int PowerStationId { get; set; }
|
||||||
|
public string inv_01 { get; set; }
|
||||||
|
public string inv_02 { get; set; }
|
||||||
|
public string inv_03 { get; set; }
|
||||||
|
public string inv_04 { get; set; }
|
||||||
|
public string inv_05 { get; set; }
|
||||||
|
public string inv_06 { get; set; }
|
||||||
|
public string inv_07 { get; set; }
|
||||||
|
public string inv_08 { get; set; }
|
||||||
|
public string inv_09 { get; set; }
|
||||||
|
public string inv_10 { get; set; }
|
||||||
|
public string inv_11 { get; set; }
|
||||||
|
public string inv_12 { get; set; }
|
||||||
|
public string inv_13 { get; set; }
|
||||||
|
public string inv_14 { get; set; }
|
||||||
|
public string inv_15 { get; set; }
|
||||||
|
public string inv_16 { get; set; }
|
||||||
|
public string inv_17 { get; set; }
|
||||||
|
public string inv_18 { get; set; }
|
||||||
|
public string inv_19 { get; set; }
|
||||||
|
public string inv_20 { get; set; }
|
||||||
|
public string inv_21 { get; set; }
|
||||||
|
public string inv_22 { get; set; }
|
||||||
|
public string inv_23 { get; set; }
|
||||||
|
public string inv_24 { get; set; }
|
||||||
|
public string inv_25 { get; set; }
|
||||||
|
public string inv_26 { get; set; }
|
||||||
|
public string inv_27 { get; set; }
|
||||||
|
public string inv_28 { get; set; }
|
||||||
|
public string inv_29 { get; set; }
|
||||||
|
public string inv_30 { get; set; }
|
||||||
|
public string inv_31 { get; set; }
|
||||||
|
public string inv_32 { get; set; }
|
||||||
|
public string inv_33 { get; set; }
|
||||||
|
public string inv_34 { get; set; }
|
||||||
|
public string inv_35 { get; set; }
|
||||||
|
public string inv_36 { get; set; }
|
||||||
|
public string inv_37 { get; set; }
|
||||||
|
public string inv_38 { get; set; }
|
||||||
|
public string inv_39 { get; set; }
|
||||||
|
public string inv_40 { get; set; }
|
||||||
|
public string inv_41 { get; set; }
|
||||||
|
public string inv_42 { get; set; }
|
||||||
|
public string inv_43 { get; set; }
|
||||||
|
public string inv_44 { get; set; }
|
||||||
|
public string inv_45 { get; set; }
|
||||||
|
public string inv_46 { get; set; }
|
||||||
|
public string inv_47 { get; set; }
|
||||||
|
public string inv_48 { get; set; }
|
||||||
|
public string inv_49 { get; set; }
|
||||||
|
public string inv_50 { get; set; }
|
||||||
|
public string inv_51 { get; set; }
|
||||||
|
public string inv_52 { get; set; }
|
||||||
|
public string inv_53 { get; set; }
|
||||||
|
public string inv_54 { get; set; }
|
||||||
|
public string inv_55 { get; set; }
|
||||||
|
public string inv_56 { get; set; }
|
||||||
|
public string inv_57 { get; set; }
|
||||||
|
public string inv_58 { get; set; }
|
||||||
|
public string inv_59 { get; set; }
|
||||||
|
public string inv_60 { get; set; }
|
||||||
|
public string inv_61 { get; set; }
|
||||||
|
public string inv_62 { get; set; }
|
||||||
|
public string inv_63 { get; set; }
|
||||||
|
public string inv_64 { get; set; }
|
||||||
|
public string inv_65 { get; set; }
|
||||||
|
public string inv_66 { get; set; }
|
||||||
|
public string inv_67 { get; set; }
|
||||||
|
public string inv_68 { get; set; }
|
||||||
|
public string inv_69 { get; set; }
|
||||||
|
public string inv_70 { get; set; }
|
||||||
|
public string inv_71 { get; set; }
|
||||||
|
public string inv_72 { get; set; }
|
||||||
|
public string inv_73 { get; set; }
|
||||||
|
public string inv_74 { get; set; }
|
||||||
|
public string inv_75 { get; set; }
|
||||||
|
public string inv_76 { get; set; }
|
||||||
|
public string inv_77 { get; set; }
|
||||||
|
public string inv_78 { get; set; }
|
||||||
|
public string inv_79 { get; set; }
|
||||||
|
public string inv_80 { get; set; }
|
||||||
|
public string inv_81 { get; set; }
|
||||||
|
public string inv_82 { get; set; }
|
||||||
|
public string inv_83 { get; set; }
|
||||||
|
public string inv_84 { get; set; }
|
||||||
|
public string inv_85 { get; set; }
|
||||||
|
public string inv_86 { get; set; }
|
||||||
|
public string inv_87 { get; set; }
|
||||||
|
public string inv_88 { get; set; }
|
||||||
|
public string inv_89 { get; set; }
|
||||||
|
public string inv_90 { get; set; }
|
||||||
|
public string inv_91 { get; set; }
|
||||||
|
public string inv_92 { get; set; }
|
||||||
|
public string inv_93 { get; set; }
|
||||||
|
public string inv_94 { get; set; }
|
||||||
|
public string inv_95 { get; set; }
|
||||||
|
public string inv_96 { get; set; }
|
||||||
|
public string inv_97 { get; set; }
|
||||||
|
public string inv_98 { get; set; }
|
||||||
|
public string inv_99 { get; set; }
|
||||||
|
public string inv_100 { get; set; }
|
||||||
|
public double hourKWH { get; set; }
|
||||||
|
public double hourKWHp { get; set; }
|
||||||
|
public double irradiance { get; set; }
|
||||||
|
public double temperature { get; set; }
|
||||||
|
public double hourmoney { get; set; }
|
||||||
|
public double totKWH { get; set; }
|
||||||
|
public double totKWHKWP { get; set; }
|
||||||
|
public double totmoney { get; set; }
|
||||||
|
public double daymoney { get; set; }
|
||||||
|
public double tothour { get; set; }
|
||||||
|
public double pr { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -91,24 +91,33 @@ namespace solarApp.Service
|
|||||||
public bool archiveData(string siteID, string date1)
|
public bool archiveData(string siteID, string date1)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
//try
|
|
||||||
//{
|
|
||||||
_siteID = siteID;
|
|
||||||
_date1 = date1;
|
|
||||||
get_siteInfo();
|
|
||||||
clearData();
|
|
||||||
insert_inv();
|
|
||||||
|
|
||||||
|
_siteID = siteID;
|
||||||
|
_date1 = date1;
|
||||||
|
get_siteInfo();
|
||||||
|
clearData();
|
||||||
|
insert_inv();
|
||||||
//日報表
|
//日報表
|
||||||
//insert_report_invDay(); get_ck_invDay_list
|
insert_report_invDay(); //get_ck_invDay_list
|
||||||
result = true;
|
|
||||||
//}
|
|
||||||
//catch (Exception ex)
|
|
||||||
//{
|
|
||||||
// throw ex;
|
|
||||||
//}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool report_invDay(string siteID, string date1)
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
_siteID = siteID;
|
||||||
|
_date1 = date1;
|
||||||
|
get_siteInfo();
|
||||||
|
|
||||||
|
//日報表
|
||||||
|
insert_report_invDay(); //get_ck_invDay_list
|
||||||
|
result = true;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public bool get_siteInfo()
|
public bool get_siteInfo()
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
@ -236,15 +245,17 @@ namespace solarApp.Service
|
|||||||
|
|
||||||
var ds = conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
|
var ds = conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
|
||||||
|
|
||||||
if (_logger != null)
|
if (_logger != null)
|
||||||
{
|
_logger.LogInformation("【ProcInvSvc】執行完成[{0}]在{1}逆變器15min補償", _siteID, _date1);
|
||||||
_logger.LogInformation("【ProcInvSvc】執行完成[{0}]在{1}逆變器15min補償", _siteID, _date1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器15min補償", _siteID, _date1);
|
|
||||||
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器15min補償 - [Exception]:{2}", _siteID, _date1, ex.ToString());
|
if (_logger != null)
|
||||||
|
{
|
||||||
|
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器15min補償", _siteID, _date1);
|
||||||
|
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器15min補償 - [Exception]:{2}", _siteID, _date1, ex.ToString());
|
||||||
|
}
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@ -252,10 +263,8 @@ namespace solarApp.Service
|
|||||||
#region hour
|
#region hour
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_logger != null)
|
if (_logger != null)
|
||||||
{
|
_logger.LogInformation("【ProcInvSvc】開始執行[{0}]在{1}逆變器hour補償", _siteID, _date1);
|
||||||
_logger.LogInformation("【ProcInvSvc】開始執行[{0}]在{1}逆變器hour補償", _siteID, _date1);
|
|
||||||
}
|
|
||||||
|
|
||||||
//sql = @"
|
//sql = @"
|
||||||
// insert into solar_master.inverter_history_hour (PowerStationId, INVERTERID, TIMESTAMP, Irradiance, AC1V, AC1A, AC1W, AC1F, AC1WH, AC2V, AC2A, AC2W, AC2F, AC2WH,
|
// insert into solar_master.inverter_history_hour (PowerStationId, INVERTERID, TIMESTAMP, Irradiance, AC1V, AC1A, AC1W, AC1F, AC1WH, AC2V, AC2A, AC2W, AC2F, AC2WH,
|
||||||
@ -351,10 +360,8 @@ namespace solarApp.Service
|
|||||||
) inv_pr
|
) inv_pr
|
||||||
ON a.reportDate = inv_pr.reportDate AND a.INVERTERID = inv_pr.INVERTERID;";
|
ON a.reportDate = inv_pr.reportDate AND a.INVERTERID = inv_pr.INVERTERID;";
|
||||||
ct = conn.Execute(sql, new { date1 = _date1 });
|
ct = conn.Execute(sql, new { date1 = _date1 });
|
||||||
if (_logger != null)
|
if (_logger != null)
|
||||||
{
|
_logger.LogInformation("【ProcInvSvc】執行完成[{0}]在{1}逆變器hour補償", _siteID, _date1);
|
||||||
_logger.LogInformation("【ProcInvSvc】執行完成[{0}]在{1}逆變器hour補償", _siteID, _date1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -409,10 +416,8 @@ namespace solarApp.Service
|
|||||||
)irr on a.reportDate = irr.reportDate ;";
|
)irr on a.reportDate = irr.reportDate ;";
|
||||||
conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
|
conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
|
||||||
|
|
||||||
if (_logger != null)
|
if (_logger != null)
|
||||||
{
|
_logger.LogInformation("【ProcInvSvc】執行完成[{0}]在{1}逆變器day補償", _siteID, _date1);
|
||||||
_logger.LogInformation("【ProcInvSvc】執行完成[{0}]在{1}逆變器day補償", _siteID, _date1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -428,10 +433,8 @@ namespace solarApp.Service
|
|||||||
#region month
|
#region month
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_logger != null)
|
if (_logger != null)
|
||||||
{
|
_logger.LogInformation("【ProcInvSvc】開始執行[{0}]在{1}逆變器month補償", _siteID, _date1);
|
||||||
_logger.LogInformation("【ProcInvSvc】開始執行[{0}]在{1}逆變器month補償", _siteID, _date1);
|
|
||||||
}
|
|
||||||
|
|
||||||
sql = @"
|
sql = @"
|
||||||
delete from inverter_history_month where powerstationID = @powerStationID and left(`TIMESTAMP`, 7) = left(@date1, 7) ;
|
delete from inverter_history_month where powerstationID = @powerStationID and left(`TIMESTAMP`, 7) = left(@date1, 7) ;
|
||||||
@ -501,7 +504,6 @@ namespace solarApp.Service
|
|||||||
_siteID = siteID;
|
_siteID = siteID;
|
||||||
_date1 = date1;
|
_date1 = date1;
|
||||||
get_siteInfo();
|
get_siteInfo();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//建立日報表
|
//建立日報表
|
||||||
@ -512,7 +514,7 @@ namespace solarApp.Service
|
|||||||
using (MySqlConnection conn = new MySqlConnection(Connection1))
|
using (MySqlConnection conn = new MySqlConnection(Connection1))
|
||||||
{
|
{
|
||||||
conn.Open();
|
conn.Open();
|
||||||
string ss = @"SET SESSION sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY,',''));";
|
string ss = @$"delete from report_invday where powerstationid = {_powerStationID} and left(report_date, 10) = '{_date1}'";
|
||||||
conn.Execute(ss);
|
conn.Execute(ss);
|
||||||
|
|
||||||
string sql = string.Empty;
|
string sql = string.Empty;
|
||||||
@ -524,52 +526,102 @@ namespace solarApp.Service
|
|||||||
_logger.LogInformation("【Proc_inv_日報 】開始執行[{0}]在{1}inv_get_SQLStatement", _siteID, _date1);
|
_logger.LogInformation("【Proc_inv_日報 】開始執行[{0}]在{1}inv_get_SQLStatement", _siteID, _date1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 取得 inv 數量
|
#region 先新增 inv_no01
|
||||||
sql = $@"select * from v_company_inv where ";
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
sql = @$"
|
sql = @$"
|
||||||
SET @sql = NULL;
|
insert report_invday(`report_date`, `PowerStationID`, inv_01, `hourKWH`, `hourKWHp`, `irradiance`, `temperature`, `hourmoney`, `pr`, createTime)
|
||||||
SELECT
|
select a.TIMESTAMP report_date, a.powerstationId , ifnull(a.kwh, 0) inv_01, ifnull(b.KWH, 0) hourKWH,
|
||||||
GROUP_CONCAT(DISTINCT
|
ifnull(round((b.KWH / (SELECT MAX(TODAYKWH) FROM power_station_history_hour
|
||||||
CONCAT('max(case when INVERTERID = ''', INVERTERID, ''' then a.KWH end) ''inv_', right(INVERTERID, 2), '''')
|
WHERE DATE_FORMAT(TIMESTAMP,'%Y-%m-%d') = '{_date1}' and powerstationid = {_powerStationID} ))*100,2)
|
||||||
) INTO @sql
|
, 0) 'hourKWHp', ifnull(d.irradiance, 0) 'irradiance', ifnull(d.Temperature, 0) 'temperature',
|
||||||
FROM inverter_history_hour where powerstationId = {_powerStationID} and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = '{_date1}';
|
ifnull(b.money, 0) 'hourmoney', ifnull(round(b.PR, 2), 0) as pr, now()
|
||||||
SET @sql = CONCAT('SELECT DATE_FORMAT(a.TIMESTAMP,''%m-%d %H'') report_date, ', @sql,
|
from inverter_history_hour a left join
|
||||||
', 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
|
( # 每小時加總 inv
|
||||||
select powerStationid, DATE_FORMAT(TIMESTAMP,''%Y-%m-%d %H:%i'') report_date, siteid, sitetype, round(KWH, 2) KWH,
|
select powerStationid, `TIMESTAMP` report_date, siteid, sitetype, round(KWH, 2) KWH,
|
||||||
round(TODAYKWH, 2) TODAYKWH,round(KWHKWP, 2) KWHKWP, round(PR, 2) PR, round(money, 2) money
|
round(TODAYKWH, 2) TODAYKWH,round(KWHKWP, 2) KWHKWP, round(PR, 2) PR, round(money, 2) money
|
||||||
from power_station_history_hour
|
from power_station_history_hour
|
||||||
where powerstationid = {_powerStationID} and DATE_FORMAT(`TIMESTAMP`,''%Y-%m-%d'') = ''{_date1}''
|
where powerstationid = {_powerStationID} and left(`TIMESTAMP`,10) = '{_date1}'
|
||||||
) b on a.powerStationid = b.powerStationid and concat(a.crdDate,' ', left(a.crdTime, 5)) = b.report_date
|
) b on a.powerStationid = b.powerStationid and a.`TIMESTAMP` = b.report_date
|
||||||
|
|
||||||
left join
|
left join
|
||||||
(
|
(
|
||||||
select powerStationID, DATE_FORMAT(TIMESTAMP,''%Y-%m-%d %H:00'')report_date, irradiance, Temperature
|
select powerStationID, DATE_FORMAT(TIMESTAMP,'%Y-%m-%d %H:00')report_date, irradiance, Temperature
|
||||||
from sensor_history_hour
|
from sensor_history_hour
|
||||||
where powerstationid = {_powerStationID} and DATE_FORMAT(`TIMESTAMP`,''%Y-%m-%d'') = ''{_date1}''
|
where powerstationid = {_powerStationID} and left(`TIMESTAMP`,10) = '{_date1}'
|
||||||
) d on a.powerStationid = d.powerStationid and concat(a.crdDate,' ', left(a.crdTime, 2), '':00'') = d.report_date
|
) d on a.powerStationid = d.powerStationid and concat(left(a.`TIMESTAMP`, 13), ':00') = d.report_date
|
||||||
where a.crdDate = ''{_date1}''
|
where a.powerstationid = {_powerStationID} and a.crdDate = '{_date1}' and right(a.inverterid, 4) = '0001'
|
||||||
GROUP BY concat(a.crdDate,' ', left(a.crdTime, 2))
|
GROUP BY left(a.`TIMESTAMP`, 13)
|
||||||
order by a.crdTime ');
|
order by a.crdTime ;";
|
||||||
select @sql as 'mySelect'; #顯示動態語法";
|
conn.Execute(sql);
|
||||||
var ds = conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
|
#endregion
|
||||||
|
|
||||||
if (_logger != null)
|
#region inv_02 之後的 kwh
|
||||||
|
#region 取得 inv 數量
|
||||||
|
sql = $@" select b.id PowerStationId, b.`name` station_name, inverterid, b.`code` station_code
|
||||||
|
from v_company_inv a join power_station b on left(a.inverterid, 9) = b.`code`
|
||||||
|
where b.`id` = '{_powerStationID}' and b.Deleted = 0 and a.`enabled` = 1 and b.`status` = 1 # 啟用 ";
|
||||||
|
var ds = conn.Query<station_inv_list>(sql).AsList<station_inv_list>();
|
||||||
|
#endregion
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
StringBuilder sb_column = new StringBuilder();
|
||||||
|
StringBuilder sb_select = new StringBuilder();
|
||||||
|
StringBuilder sb_update_columns = new StringBuilder();
|
||||||
|
|
||||||
|
for (int i = 0; i < ds.Count; i++)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("【Proc_inv_日報】執行完成[{0}]在{1} inv_get_SQLStatement", _siteID, _date1);
|
if (i == 0) continue;
|
||||||
|
if (i < 9)
|
||||||
|
{
|
||||||
|
sb_column.Append(@$", `inv_0{(i + 1).ToString()}`");
|
||||||
|
if (i == 1)
|
||||||
|
{
|
||||||
|
sb.Append(@" update report_invday a join (
|
||||||
|
select a02.powerstationID, a02.report_date, ifnull(a02.inv_02, 0) inv_02");
|
||||||
|
sb_select.Append(@$" from
|
||||||
|
(select powerstationID, `TIMESTAMP` report_date, kwh inv_02 from inverter_history_hour a
|
||||||
|
where a.powerstationid = {_powerStationID} and a.crdDate = '{_date1}' and right(a.inverterid, 4) = '000{(i + 1).ToString()}') a0{(i + 1).ToString()} ");
|
||||||
|
sb_update_columns.Append($@" ) b
|
||||||
|
on a.powerstationid = b.powerstationid and a.report_date = b.report_date
|
||||||
|
set a.inv_02 = b.inv_02 ");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sb.Append(@$" , ifnull(a0{(i + 1).ToString()}.inv_0{(i + 1).ToString()}, 0) inv_0{(i + 1).ToString()}");
|
||||||
|
sb_select.Append($@" left join (select `TIMESTAMP` report_date, kwh inv_0{(i + 1).ToString()} from inverter_history_hour a
|
||||||
|
where a.powerstationid = {_powerStationID} and a.crdDate = '{_date1}' and right(a.inverterid, 4) = '000{(i + 1).ToString()}') a0{(i + 1).ToString()} on a02.report_date = a0{(i + 1).ToString()}.report_date ");
|
||||||
|
sb_update_columns.Append($@", a.inv_0{(i + 1).ToString()} = b.inv_0{(i + 1).ToString()}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sb.Append(@$" , ifnull(a{(i + 1).ToString()}.inv_{(i + 1).ToString()}, 0) inv_{(i + 1).ToString()} ");
|
||||||
|
sb_column.Append(@$", `inv_{(i + 1).ToString()}`");
|
||||||
|
sb_select.Append($@" left join (select `TIMESTAMP` report_date, kwh inv_{(i + 1).ToString()} from inverter_history_hour a
|
||||||
|
where a.powerstationid = {_powerStationID} and a.crdDate = '{_date1}' and right(a.inverterid, 4) = '00{(i + 1).ToString()}') a{(i + 1).ToString()} on a02.report_date = a{(i + 1).ToString()}.report_date ");
|
||||||
|
sb_update_columns.Append($@", a.inv_{(i + 1).ToString()} = b.inv_{(i + 1).ToString()}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// sb.Append(", `hourKWH`, `hourKWHp`, `irradiance`, `temperature`, `hourmoney`, `pr`)");
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region insert report_invDay
|
||||||
|
sb_column.Clear();
|
||||||
|
sql = sb.ToString() + sb_select.ToString() + sb_update_columns.ToString();
|
||||||
|
conn.Execute(sql);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
if (_logger != null)
|
||||||
|
_logger.LogInformation("【Proc_inv_日報 table 】執行完成[{0}]在{1} inv_get_SQLStatement", _siteID, _date1);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError("【Proc_inv_日報】執行失敗[{0}]在{1}inv_get_SQLStatement", _siteID, _date1);
|
if (_logger != null)
|
||||||
_logger.LogError("【Proc_inv_日報】執行失敗[{0}]在{1}inv_get_SQLStatement - [Exception]:{2}", _siteID, _date1, ex.ToString());
|
{
|
||||||
|
_logger.LogError("【Proc_inv_日報 table】執行失敗[{0}]在{1}inv_get_SQLStatement", _siteID, _date1);
|
||||||
|
_logger.LogError("【Proc_inv_日報 table】執行失敗[{0}]在{1}inv_get_SQLStatement - [Exception]:{2}", _siteID, _date1, ex.ToString());
|
||||||
|
}
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -37,7 +37,7 @@ namespace solarApp
|
|||||||
foreach (DateTime day in EachDay(DateTime.Parse(date1), DateTime.Parse(date2)))
|
foreach (DateTime day in EachDay(DateTime.Parse(date1), DateTime.Parse(date2)))
|
||||||
{
|
{
|
||||||
//string d1 = day.ToString("yyyy-MM-dd");
|
//string d1 = day.ToString("yyyy-MM-dd");
|
||||||
sensorSvc.archiveData(lbSiteID_sensor.Text.Substring(0, 9), date1);
|
sensorSvc.archiveData(lbSiteID_sensor.Text.Substring(0, 9), day.ToString("yyyy-MM-dd"));
|
||||||
}
|
}
|
||||||
//sensorSvc._siteDB = lbSiteDB_sensor.Text;
|
//sensorSvc._siteDB = lbSiteDB_sensor.Text;
|
||||||
//sensorSvc._siteID = lbSiteID_sensor.Text.Substring(0, 9);
|
//sensorSvc._siteID = lbSiteID_sensor.Text.Substring(0, 9);
|
||||||
@ -178,7 +178,7 @@ namespace solarApp
|
|||||||
foreach (DateTime day in EachDay(DateTime.Parse(date1), DateTime.Parse(date2)))
|
foreach (DateTime day in EachDay(DateTime.Parse(date1), DateTime.Parse(date2)))
|
||||||
{
|
{
|
||||||
//string d1 = day.ToString("yyyy-MM-dd");
|
//string d1 = day.ToString("yyyy-MM-dd");
|
||||||
siteSvc.archiveData(lbSiteID_sensor.Text.Substring(0, 9), date1);
|
siteSvc.archiveData(lbSiteID_sensor.Text.Substring(0, 9), day.ToString("yyyy-MM-dd"));
|
||||||
}
|
}
|
||||||
//sensorSvc.archiveData();
|
//sensorSvc.archiveData();
|
||||||
MessageBox.Show("OK");
|
MessageBox.Show("OK");
|
||||||
@ -225,15 +225,14 @@ namespace solarApp
|
|||||||
private void bt_rpt_invDay_Click(object sender, EventArgs e)
|
private void bt_rpt_invDay_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
string date1 = dtSelect1.Value.ToString("yyyy-MM-dd");
|
string date1 = dtSelect1.Value.ToString("yyyy-MM-dd");
|
||||||
//procSensorSvc sensorSvc = new procSensorSvc(lbSiteDB_sensor.Text, lbSiteID_sensor.Text, date1, date1);
|
string date2 = dtSelect2.Value.ToString("yyyy-MM-dd");
|
||||||
procInvSvc invSvc = new procInvSvc();
|
procInvSvc invSvc = new procInvSvc();
|
||||||
//invSvc._siteDB = lbSiteDB_sensor.Text;
|
|
||||||
//invSvc._siteID = lbSiteID_sensor.Text.Substring(0, 9);
|
foreach (DateTime day in EachDay(DateTime.Parse(date1), DateTime.Parse(date2)))
|
||||||
//invSvc._siteID01 = lbSiteID_sensor.Text;
|
{
|
||||||
//invSvc._date1 = date1;
|
invSvc.report_invDay(lbSiteID_sensor.Text.Substring(0, 9), day.ToString("yyyy-MM-dd"));
|
||||||
//invSvc._date2 = date1;
|
}
|
||||||
invSvc.archiveData(lbSiteID_sensor.Text.Substring(0, 9), date1);
|
|
||||||
//sensorSvc.archiveData();
|
|
||||||
MessageBox.Show("OK");
|
MessageBox.Show("OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user