歸檔取消 Exception
This commit is contained in:
parent
26da763cbb
commit
9475fff227
@ -162,7 +162,8 @@
|
||||
<script>
|
||||
var localurl = this.location.href;
|
||||
var powerids = new Array(0);//當前選擇電站
|
||||
var Type = 2; // //工作項目, 0:清洗 1:巡檢 2:維修
|
||||
var Type = 0; // //程式中 會自動-1, 工作項目, 0:清洗 1:巡檢 2:維修
|
||||
var OperationStatus = 0; //運維 - 完成狀態
|
||||
var stationId;
|
||||
var errortoID;
|
||||
var powerStationData;
|
||||
@ -1031,6 +1032,7 @@
|
||||
"data": function (d) {
|
||||
d.PowerStationIds = powerids;
|
||||
d.WorkType = Type;
|
||||
d.Status = OperationStatus;
|
||||
d.Range = $('#date-range').val();
|
||||
},
|
||||
"dataSrc": function (rel) {
|
||||
@ -2031,6 +2033,24 @@
|
||||
$('#date-range-record').on('change', function () {
|
||||
operationRecordTable.ajax.reload();
|
||||
});
|
||||
//#endregion
|
||||
|
||||
//#region 改狀態
|
||||
function CheckStatus(type, e) {
|
||||
$('#operation_record_table_wrapper').hide();
|
||||
OperationStatus = type;
|
||||
if ($(".status-type").hasClass("btn-success")) {
|
||||
$(".status-type").removeClass("btn-success").addClass("btn-secondary");
|
||||
}
|
||||
$(e).removeClass("btn-secondary").addClass("btn-success");
|
||||
//if (OperationStatus == 2) {
|
||||
// operationRecordTable.column(10).visible(true);
|
||||
//}
|
||||
//else {
|
||||
// operationRecordTable.column(10).visible(false);
|
||||
//}
|
||||
operationRecordTable.ajax.reload();
|
||||
}
|
||||
//#endregion
|
||||
|
||||
//#region 改變項目(運維)
|
||||
|
||||
@ -7,6 +7,13 @@
|
||||
<button type="button" class="btn btn-secondary waves-effect waves-themed" onclick="ChangeType(1)" id="button1">清洗</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pr-3">
|
||||
<div class="btn-group btn-group-md">
|
||||
<button type="button" class="btn btn-success waves-effect waves-themed status-type" onclick="CheckStatus(0,this)">未完成</button>
|
||||
<button type="button" class="btn btn-secondary waves-effect waves-themed status-type" onclick="CheckStatus(1,this)">完成</button>
|
||||
<button type="button" class="btn btn-secondary waves-effect waves-themed status-type" onclick="CheckStatus(2,this)">刪除區</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pr-3">
|
||||
<button type="button" class="btn btn-secondary waves-effect waves-themed" onclick="ChangeDate30()">近30天</button>
|
||||
</div>
|
||||
|
||||
@ -193,7 +193,8 @@ namespace solarApp.Service
|
||||
conn.Open(); // 01 控制器編號
|
||||
string sql = @" select id, CompanyId, `code` , SerialNumber, CONCAT(`code` ,'01') SiteID, SiteDB, `name` SiteName
|
||||
from power_station
|
||||
where deleted = 0 and `status`= 1 ";
|
||||
where deleted = 0 and `status`= 1
|
||||
ORDER BY GeneratingCapacity ";
|
||||
// id <> 14";and id > 24
|
||||
List<station_list> ds = conn.Query<station_list>(sql).AsList<station_list>();
|
||||
conn.Close();
|
||||
|
||||
@ -41,16 +41,17 @@ namespace solarApp.Service
|
||||
//public string _date2 { get; set; }
|
||||
public string _powerStationID { get; set; }
|
||||
|
||||
procArchiveLog arclog = new procArchiveLog();
|
||||
|
||||
public bool clearData()
|
||||
{
|
||||
bool result = false;
|
||||
try
|
||||
{
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
using (MySqlConnection conn = new MySqlConnection(Connection1))
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
try
|
||||
{
|
||||
if (_logger != null)
|
||||
{
|
||||
_logger.LogInformation("【ProcInvSvc】開始執行[{0}]在{1}逆變器清除資料表的資料", _siteID, _date1);
|
||||
@ -67,7 +68,7 @@ namespace solarApp.Service
|
||||
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 });
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandTimeout = 360;
|
||||
cmd.Parameters.AddWithValue("@date1", _date1);
|
||||
@ -80,9 +81,6 @@ namespace solarApp.Service
|
||||
{
|
||||
_logger.LogInformation("【ProcInvSvc】執行完成[{0}]在{1}逆變器清除資料表的資料", _siteID, _date1);
|
||||
}
|
||||
|
||||
conn.Close();
|
||||
}
|
||||
result = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -92,7 +90,11 @@ namespace solarApp.Service
|
||||
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器清除資料表的資料", _siteID, _date1);
|
||||
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器清除資料表的資料 - [Exception]:{2}", _siteID, _date1, ex.ToString());
|
||||
}
|
||||
throw ex;
|
||||
//throw ex;
|
||||
arclog.insert_log(_powerStationID, "step0 del inv ", 0, "inv", "del inv error", "0", "", "", conn, cmd);
|
||||
|
||||
}
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -130,12 +132,11 @@ namespace solarApp.Service
|
||||
public bool get_siteInfo()
|
||||
{
|
||||
bool result = false;
|
||||
try
|
||||
{
|
||||
using (MySqlConnection conn = new MySqlConnection(Connection1))
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
try
|
||||
{
|
||||
if (_logger != null)
|
||||
{
|
||||
_logger.LogInformation("【ProcInvSvc】開始執行[{0}]在{1}逆變器取得電站編號", _siteID, _date1);
|
||||
@ -158,8 +159,7 @@ namespace solarApp.Service
|
||||
}
|
||||
|
||||
#endregion
|
||||
conn.Close();
|
||||
}
|
||||
|
||||
result = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -169,14 +169,16 @@ namespace solarApp.Service
|
||||
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器取得電站編號", _siteID, _date1);
|
||||
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器取得電站編號 - [Exception]:{2}", _siteID, _date1, ex.ToString());
|
||||
}
|
||||
|
||||
throw ex;
|
||||
arclog.insert_log(_powerStationID, "step0 select stationID ", 0, "stationID", "select stationID", "0", "", "", conn, null);
|
||||
}
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
bool insert_inv()
|
||||
{
|
||||
bool result = false;
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
//try
|
||||
//{
|
||||
using (MySqlConnection conn = new MySqlConnection(Connection1))
|
||||
@ -201,7 +203,6 @@ namespace solarApp.Service
|
||||
# 2. add index
|
||||
ALTER TABLE del_Inv_day_" + _powerStationID + @"_s1 ADD INDEX `temp_index` (crdTime, inverterid);";
|
||||
//int ct = conn.Execute(sql, new { date1 = _date1 });
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandTimeout = 360;
|
||||
cmd.Parameters.AddWithValue("@date1", _date1);
|
||||
@ -209,7 +210,6 @@ namespace solarApp.Service
|
||||
cmd.ExecuteNonQuery();
|
||||
cmd.Parameters.Clear();
|
||||
|
||||
|
||||
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
|
||||
@ -239,36 +239,6 @@ namespace solarApp.Service
|
||||
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(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 '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 });
|
||||
cmd.Parameters.AddWithValue("@date1", _date1);
|
||||
@ -289,7 +259,7 @@ namespace solarApp.Service
|
||||
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器15min補償", _siteID, _date1);
|
||||
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器15min補償 - [Exception]:{2}", _siteID, _date1, ex.ToString());
|
||||
}
|
||||
throw ex;
|
||||
arclog.insert_log(_powerStationID, "step1 insert inverter_15min history", 0, "inverter_history_15min", "insert inverter_15min history", "0", "", "", conn, cmd);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -299,50 +269,6 @@ namespace solarApp.Service
|
||||
if (_logger != null)
|
||||
_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)
|
||||
|
||||
// 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 });
|
||||
|
||||
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,
|
||||
@ -374,7 +300,6 @@ namespace solarApp.Service
|
||||
)irr on a.reportDate = irr.reportDate
|
||||
where i.enabled = 1;";
|
||||
//int ct = conn.Execute(sql, new { date1 = _date1 });
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandTimeout = 720;
|
||||
cmd.Parameters.AddWithValue("@date1", _date1);
|
||||
@ -406,7 +331,6 @@ namespace solarApp.Service
|
||||
cmd.CommandText = sql;
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_logger != null)
|
||||
@ -414,7 +338,8 @@ namespace solarApp.Service
|
||||
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器hour補償", _siteID, _date1);
|
||||
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器hour補償 - [Exception]:{2}", _siteID, _date1, ex.ToString());
|
||||
}
|
||||
throw ex;
|
||||
arclog.insert_log(_powerStationID, "inverter_history_hour step1 ", 0, "inverter_history_hour", "insert inverter_history_hour error", "0", "", "", conn, cmd);
|
||||
// throw ex;
|
||||
}
|
||||
|
||||
#endregion hour
|
||||
@ -460,7 +385,6 @@ namespace solarApp.Service
|
||||
)irr on a.reportDate = irr.reportDate
|
||||
where i.enabled = 1;";
|
||||
// conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandTimeout = 360;
|
||||
cmd.Parameters.AddWithValue("@date1", _date1);
|
||||
@ -480,7 +404,8 @@ namespace solarApp.Service
|
||||
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器day補償", _siteID, _date1);
|
||||
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器day補償 - [Exception]:{2}", _siteID, _date1, ex.ToString());
|
||||
}
|
||||
throw ex;
|
||||
//throw ex;
|
||||
arclog.insert_log(_powerStationID, "inverter_history_day step1 ", 0, "inverter_history_day", "insert inverter_history_day error", "0", "", "", conn, cmd);
|
||||
}
|
||||
#endregion day
|
||||
|
||||
@ -525,7 +450,6 @@ namespace solarApp.Service
|
||||
)irr on a.reportDate = irr.reportDate
|
||||
where i.enabled = 1;";
|
||||
//conn.Execute(sql, new { date1 = _date1.Substring(0, 7), PowerStationID = _powerStationID });
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandTimeout = 360;
|
||||
cmd.Parameters.AddWithValue("@date1", _date1.Substring(0, 7));
|
||||
@ -546,7 +470,8 @@ namespace solarApp.Service
|
||||
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器month補償", _siteID, _date1);
|
||||
_logger.LogError("【ProcInvSvc】執行失敗[{0}]在{1}逆變器month補償 - [Exception]:{2}", _siteID, _date1, ex.ToString());
|
||||
}
|
||||
throw ex;
|
||||
arclog.insert_log(_powerStationID, "inverter_history_month step1 ", 0, "inverter_history_month", "insert inverter_history_month error", "0", "", "", conn, cmd);
|
||||
// throw ex;
|
||||
}
|
||||
|
||||
#endregion month
|
||||
@ -583,7 +508,7 @@ namespace solarApp.Service
|
||||
arclog.insert_log(_powerStationID, "report_day step > 開始執行", (DateTime.Now - dt_start).TotalSeconds, "inverter_history_hour", "temp_invDay", "0", "", "日報 開始執行", conn, cmd);
|
||||
string sql = @$"delete from report_invday where powerstationid = {_powerStationID} and left(report_date, 10) = '{_date1}'";
|
||||
conn.Execute(sql);
|
||||
arclog.insert_log(_powerStationID, "report_day step > 刪除 report_invday", (DateTime.Now - dt_start).TotalSeconds, "inverter_history_hour", "temp_invDay", "0", "", "日報 刪除 report_invday", conn, cmd);
|
||||
arclog.insert_log(_powerStationID, "report_day step > 刪除 report_invday", (DateTime.Now - dt_start).TotalSeconds, "inverter_history_hour", "temp_invDay", "1", "", "日報 刪除 report_invday", conn, cmd);
|
||||
|
||||
#region get SQL
|
||||
//try
|
||||
@ -604,11 +529,11 @@ CREATE TABLE temp_invDay{_powerStationID}_s1
|
||||
ALTER TABLE `temp_invDay{_powerStationID}_s1` ADD INDEX `temp_indexs1` (report_date, inverterid);";
|
||||
//conn.Execute(ss);
|
||||
|
||||
arclog.insert_log(_powerStationID, "report_day step > table 建立完成", (DateTime.Now - dt_start).TotalSeconds, "inverter_history_hour", "temp_invDay", "0", "", "日報 建立table完成", conn, cmd);
|
||||
arclog.insert_log(_powerStationID, "report_day step > table 建立完成", (DateTime.Now - dt_start).TotalSeconds, "inverter_history_hour", "temp_invDay", "1", "", "日報 建立table完成", conn, cmd);
|
||||
|
||||
try
|
||||
{
|
||||
arclog.insert_log(_powerStationID, "report_day step try", (DateTime.Now - dt_start).TotalSeconds, "inverter_history_hour", "temp_invDay", "0", "", "start 日報 try", conn, cmd);
|
||||
arclog.insert_log(_powerStationID, "report_day step try", (DateTime.Now - dt_start).TotalSeconds, "inverter_history_hour", "temp_invDay", "1", "", "start 日報 try", conn, cmd);
|
||||
cmd.CommandText = sql;
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
@ -616,13 +541,13 @@ ALTER TABLE `temp_invDay{_powerStationID}_s1` ADD INDEX `temp_indexs1` (report_d
|
||||
var rowCT = cmd.ExecuteScalar();
|
||||
//select LAST_INSERT_ID()
|
||||
TimeSpan duration = DateTime.Now - dt_start;
|
||||
arclog.insert_log(_powerStationID, "report_day step1", duration.TotalSeconds, "inverter_history_hour", "temp_invDay", "0", "", rowCT.ToString(), conn, cmd);
|
||||
arclog.insert_log(_powerStationID, "report_day step1", duration.TotalSeconds, "inverter_history_hour", "temp_invDay", "1", "", rowCT.ToString(), conn, cmd);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TimeSpan duration = DateTime.Now - dt_start;
|
||||
arclog.insert_log(_powerStationID, "report_day step1", duration.TotalSeconds, "inverter_history_hour", "temp_invDay", "1", "", ex.Message, conn, cmd);
|
||||
arclog.insert_log(_powerStationID, "report_day step1", duration.TotalSeconds, "inverter_history_hour", "temp_invDay", "0", "", ex.Message, conn, cmd);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -661,12 +586,12 @@ from temp_invDay{_powerStationID}_s1 a join
|
||||
//cmd.CommandText = @$"select count(*) ct from report_invday where powerStationID = {_powerStationID} and left(`TIMESTAMP`,10) = '{_date1}'";
|
||||
//var rowCT = cmd.ExecuteScalar();
|
||||
TimeSpan duration = DateTime.Now - dt_start2 ;
|
||||
arclog.insert_log(_powerStationID, "report_day step2 inv_no01", duration.TotalSeconds, "inverter_history_hour", "report_invday", "0", "", rowCT.ToString(), conn, cmd);
|
||||
arclog.insert_log(_powerStationID, "report_day step2 inv_no01", duration.TotalSeconds, "inverter_history_hour", "report_invday", "1", "", rowCT.ToString(), conn, cmd);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TimeSpan duration = DateTime.Now - dt_start2 ;
|
||||
arclog.insert_log(_powerStationID, "report_day step2 inv_no01", duration.TotalSeconds, "inverter_history_hour", "report_invday", "1", "", ex.Message, conn, cmd);
|
||||
arclog.insert_log(_powerStationID, "report_day step2 inv_no01", duration.TotalSeconds, "inverter_history_hour", "report_invday", "0", "", ex.Message, conn, cmd);
|
||||
}
|
||||
|
||||
// conn.Execute(sql);
|
||||
@ -745,19 +670,18 @@ set a.inv_02 = b.inv_02 ");
|
||||
_logger.LogInformation("【Proc_inv_日報 table 】執行完成[{0}]在{1} inv_get_SQLStatement", _siteID, _date1);
|
||||
|
||||
TimeSpan duration = DateTime.Now - dt_start3;
|
||||
arclog.insert_log(_powerStationID, "report_day step3 update inv02", duration.TotalSeconds, "inverter_history_hour", "report_invday", "0", "", rowCT.ToString(), conn, cmd);
|
||||
arclog.insert_log(_powerStationID, "report_day step3 update inv02", duration.TotalSeconds, "inverter_history_hour", "report_invday", "1", "", rowCT.ToString(), conn, cmd);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TimeSpan duration = DateTime.Now - dt_start3 ;
|
||||
arclog.insert_log(_powerStationID, "report_day step3 update inv02", duration.TotalSeconds, "inverter_history_hour", "report_invday", "1", "", ex.Message, conn, cmd);
|
||||
arclog.insert_log(_powerStationID, "report_day step3 update inv02", duration.TotalSeconds, "inverter_history_hour", "report_invday", "0", "", ex.Message, conn, cmd);
|
||||
if (_logger != null)
|
||||
{
|
||||
_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;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -6,6 +6,9 @@ using Dapper;
|
||||
using solarApp.Model;
|
||||
using System.Configuration;
|
||||
using System.Threading.Tasks;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using MySqlX.XDevAPI.Relational;
|
||||
using static solarApp.Model.weather_model;
|
||||
|
||||
namespace solarApp.Service
|
||||
{
|
||||
@ -138,7 +141,7 @@ namespace solarApp.Service
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
//throw ex;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -207,6 +210,9 @@ namespace solarApp.Service
|
||||
sql = @"SET SESSION sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY,',''));";
|
||||
conn.Execute(sql);
|
||||
|
||||
//全域使用
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
|
||||
#region 獲取 Sensor 類別
|
||||
//沒有被刪除、啟用中、狀態正常的 才可列入計算
|
||||
//sql = @"select a.id, CONCAT( left(UID, 9) ,'01') SiteID, a.`name` sensorName, type, DBName, TableName, colname
|
||||
@ -288,7 +294,7 @@ namespace solarApp.Service
|
||||
//cmd.Parameters()
|
||||
//cmd.ExecuteNonQuery();
|
||||
//conn.Execute(sql, new { powerStationID = _powerStationID, date1 = _date1 });
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandTimeout = 720;
|
||||
cmd.Parameters.AddWithValue("@powerStationID", _powerStationID);
|
||||
@ -298,7 +304,7 @@ namespace solarApp.Service
|
||||
cmd.Parameters.Clear();
|
||||
DateTime dt_start2 = DateTime.Now;
|
||||
TimeSpan duration = DateTime.Now - dt_start2;
|
||||
arclog.insert_log(_powerStationID, "sensor step1", duration.TotalSeconds, "sensor_history_hour", "insert sensor hour", "0", "", rowCT.ToString(), conn, cmd);
|
||||
arclog.insert_log(_powerStationID, "sensor step1", duration.TotalSeconds, "sensor_history_hour", "insert sensor hour", "1", "", rowCT.ToString(), conn, cmd);
|
||||
|
||||
// irrDayHour計算
|
||||
//sql = $@"update sensor_history_hour a join (
|
||||
@ -379,6 +385,8 @@ namespace solarApp.Service
|
||||
cmd.CommandText = sql;
|
||||
cmd.ExecuteNonQuery();
|
||||
cmd.Parameters.Clear();
|
||||
arclog.insert_log(_powerStationID, "sensor step1", duration.TotalSeconds, "sensor_history_day", "insert sensor_day", "1", "", rowCT.ToString(), conn, cmd);
|
||||
|
||||
#endregion day
|
||||
|
||||
#region month 如果跨月 會有2筆資料
|
||||
@ -430,6 +438,7 @@ namespace solarApp.Service
|
||||
cmd.CommandText = sql;
|
||||
cmd.ExecuteNonQuery();
|
||||
cmd.Parameters.Clear();
|
||||
arclog.insert_log(_powerStationID, "sensor step1", duration.TotalSeconds, "sensor_history_hour", "insert sensor_hour", "1", "", rowCT.ToString(), conn, cmd);
|
||||
|
||||
//日照計 update
|
||||
sql = string.Empty;
|
||||
@ -548,13 +557,16 @@ namespace solarApp.Service
|
||||
}
|
||||
#endregion
|
||||
|
||||
conn.Close();
|
||||
|
||||
result = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
arclog.insert_log(_powerStationID, "sensor step1 ", 0, "sensor_history_", "insert sensor error", "0", "", "", conn, cmd);
|
||||
|
||||
//throw ex;
|
||||
}
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -570,13 +582,14 @@ namespace solarApp.Service
|
||||
using (MySqlConnection conn = new MySqlConnection(Connection1))
|
||||
{
|
||||
conn.Open();
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
string sql;
|
||||
//電表
|
||||
DateTime dt_start = DateTime.Now;
|
||||
try
|
||||
{
|
||||
#region hour
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandTimeout = 720;
|
||||
|
||||
@ -611,13 +624,14 @@ namespace solarApp.Service
|
||||
arclog.insert_log(_powerStationID, "sensor step1 for irrDayHour", duration.TotalSeconds, "sensor_history_hour", "update sensor hour", "0", "", rowCT2.ToString(), conn, cmd);
|
||||
#endregion hour
|
||||
|
||||
conn.Close();
|
||||
result = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
arclog.insert_log(_powerStationID, "sensor step1 irrDayHour", 0, "sensor_history_", "sensor_history_hour error", "0", "", "", conn, cmd);
|
||||
//throw ex;
|
||||
}
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -644,6 +658,7 @@ namespace solarApp.Service
|
||||
|
||||
bool insert_meter() {
|
||||
bool result = false;
|
||||
procArchiveLog arclog = new procArchiveLog();
|
||||
using (MySqlConnection conn = new MySqlConnection(Connection1))
|
||||
{
|
||||
conn.Open();
|
||||
@ -700,7 +715,8 @@ namespace solarApp.Service
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
//throw ex;
|
||||
arclog.insert_log(_powerStationID, "sensor step1 meter_hour", 0, "meter_history_hour", "meter_history_hour error", "0", "", "", conn, null);
|
||||
}
|
||||
conn.Close();
|
||||
}
|
||||
@ -714,13 +730,15 @@ namespace solarApp.Service
|
||||
bool update_invdayhour()
|
||||
{
|
||||
bool result = false;
|
||||
try
|
||||
{
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
procArchiveLog arclog = new procArchiveLog();
|
||||
using (MySqlConnection conn = new MySqlConnection(Connection1))
|
||||
{
|
||||
conn.Open();
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
string sql = $@"update sensor_history_hour a join
|
||||
(
|
||||
select powerstationID, `TIMESTAMP`, irrday -
|
||||
@ -738,12 +756,15 @@ namespace solarApp.Service
|
||||
dt_start2 = DateTime.Now;
|
||||
TimeSpan duration = DateTime.Now - dt_start2;
|
||||
arclog.insert_log(_powerStationID, "sensor step1 for irrDayHour", duration.TotalSeconds, "sensor_history_hour", "update sensor hour", "0", "", rowCT2.ToString(), conn, cmd);
|
||||
}
|
||||
|
||||
result = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
//throw ex;
|
||||
arclog.insert_log(_powerStationID, "sensor step1 meter_hour", 0, "meter_history_hour", "meter_history_hour error", "0", "", "", conn, null);
|
||||
}
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
|
||||
@ -754,6 +775,9 @@ namespace solarApp.Service
|
||||
procArchiveLog arclog = new procArchiveLog();
|
||||
bool result = false;
|
||||
bool isFirst = true;
|
||||
int rowCT = 0;
|
||||
TimeSpan duration = DateTime.Now - DateTime.Now;
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
using (MySqlConnection conn = new MySqlConnection(Connection1))
|
||||
{
|
||||
conn.Open();
|
||||
@ -843,16 +867,16 @@ namespace solarApp.Service
|
||||
//cmd.Parameters()
|
||||
//cmd.ExecuteNonQuery();
|
||||
//conn.Execute(sql, new { powerStationID = _powerStationID, date1 = _date1 });
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandTimeout = 720;
|
||||
cmd.Parameters.AddWithValue("@powerStationID", _powerStationID);
|
||||
cmd.Parameters.AddWithValue("@date1", _date1);
|
||||
cmd.CommandText = sql;
|
||||
int rowCT = cmd.ExecuteNonQuery();
|
||||
rowCT = cmd.ExecuteNonQuery();
|
||||
cmd.Parameters.Clear();
|
||||
DateTime dt_start2 = DateTime.Now;
|
||||
TimeSpan duration = DateTime.Now - dt_start2;
|
||||
duration = DateTime.Now - dt_start2;
|
||||
arclog.insert_log(_powerStationID, "sensor step1", duration.TotalSeconds, "sensor_history_hour", "insert sensor hour", "0", "", rowCT.ToString(), conn, cmd);
|
||||
|
||||
// irrDayHour計算
|
||||
@ -888,10 +912,10 @@ namespace solarApp.Service
|
||||
and a.powerstationID = {_powerStationID} ";
|
||||
dt_start2 = DateTime.Now;
|
||||
cmd.CommandText = sql;
|
||||
int rowCT2 = cmd.ExecuteNonQuery();
|
||||
rowCT = cmd.ExecuteNonQuery();
|
||||
cmd.Parameters.Clear();
|
||||
duration = DateTime.Now - dt_start2;
|
||||
arclog.insert_log(_powerStationID, "sensor step1 for irrDayHour", duration.TotalSeconds, "sensor_history_hour", "update sensor hour", "0", "", rowCT2.ToString(), conn, cmd);
|
||||
arclog.insert_log(_powerStationID, "sensor step1 for irrDayHour", duration.TotalSeconds, "sensor_history_hour", "update sensor hour", "0", "", rowCT.ToString(), conn, cmd);
|
||||
|
||||
|
||||
//sql = $@"update sensor_history_hour a join
|
||||
@ -1057,14 +1081,18 @@ namespace solarApp.Service
|
||||
|
||||
#endregion
|
||||
|
||||
conn.Close();
|
||||
|
||||
result = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
arclog.insert_log(_powerStationID, "sensor step1 for irrDayHour", duration.TotalSeconds, "sensor_history_hour", "update sensor hour", "0", "", rowCT.ToString(), conn, cmd);
|
||||
|
||||
//throw ex;
|
||||
}
|
||||
conn.Close();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
2
solarApp/fmArchive.Designer.cs
generated
2
solarApp/fmArchive.Designer.cs
generated
@ -760,7 +760,7 @@ namespace solarApp
|
||||
this.ClientSize = new System.Drawing.Size(1782, 953);
|
||||
this.Controls.Add(this.tabControl1);
|
||||
this.Name = "fmArchive";
|
||||
this.Text = "fmArchive 07-01 拯救 Kevin";
|
||||
this.Text = "fmArchive 08-05 拯救 Kevin";
|
||||
this.Load += new System.EventHandler(this.fmArchive_Load);
|
||||
this.tabControl1.ResumeLayout(false);
|
||||
this.tabPage1.ResumeLayout(false);
|
||||
|
||||
@ -353,12 +353,12 @@ namespace solarApp
|
||||
//rb.Name = item.SiteID;
|
||||
//rb.Text = item.SiteName;
|
||||
//rb.Tag = item.SiteDB;
|
||||
foreach (DateTime day in EachDay(DateTime.Parse(date1), DateTime.Parse(date2)))
|
||||
{
|
||||
sensorSvc.archiveData(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd"));
|
||||
invSvc.archiveData(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd"));
|
||||
siteSvc.archiveData(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd"));
|
||||
}
|
||||
//foreach (DateTime day in EachDay(DateTime.Parse(date1), DateTime.Parse(date2)))
|
||||
//{
|
||||
// sensorSvc.archiveData(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd"));
|
||||
// invSvc.archiveData(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd"));
|
||||
// siteSvc.archiveData(item.SiteID.Substring(0, 9), day.ToString("yyyy-MM-dd"));
|
||||
//}
|
||||
}
|
||||
sensorSvc.isFirst = true;
|
||||
foreach (var item in site_list)
|
||||
@ -589,7 +589,11 @@ namespace solarApp
|
||||
lbMsgTitle.Text = DateTime.Now.ToString() + " lackStation OK";
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// bt_archive 每日歸檔
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void bt_archive_One_Click(object sender, EventArgs e)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user