diff --git a/solarApp/Service/procSensorSvc.cs b/solarApp/Service/procSensorSvc.cs index b3857cc..992ed17 100644 --- a/solarApp/Service/procSensorSvc.cs +++ b/solarApp/Service/procSensorSvc.cs @@ -212,7 +212,7 @@ namespace solarApp.Service //sql = @"select a.id, CONCAT( left(UID, 9) ,'01') SiteID, a.`name` sensorName, type, DBName, TableName, colname // from " + _siteDB + @".device a // where left(UID, 11) = @siteID and deleted = 0 and enabled = 1 and `status` = 1 "; - sql = @$"select a.id, CONCAT( {_siteID} ,'01') SiteID, a.`name` sensorName, type, DBName, TableName, colname + sql = @$"select a.id, CONCAT( '{_siteID}' ,'01') SiteID, a.`name` sensorName, type, DBName, TableName, colname from {_siteDB}.device a left join {_siteDB}.sharedevice b on a.id = b.deviceID where (left(UID, 11) = @siteID or b.PowerStationID = {_powerStationID}) and deleted = 0 and enabled = 1 and `status` = 1 "; List ds_sensor = conn.Query(sql, new { siteID = _siteID01 }).AsList(); @@ -227,11 +227,11 @@ namespace solarApp.Service // { "Name":" 電表","EName":"PWR"}]} // { "Name":"風向計","EName":"WIN"}]} // { "Name":" 累計日照計","EName":"TPY"}]} - var irrlst = ds_sensor.FindAll(x => x.type.Contains("PYR")); - var modelTemplst = ds_sensor.FindAll(x => x.type.Contains("MTR")); - var envTemplst = ds_sensor.FindAll(x => x.type.Contains("ETR")); - var humlst = ds_sensor.FindAll(x => x.type.Contains("EMM")); - var vandlst = ds_sensor.FindAll(x => x.type.Contains("VAN")); + var irrlst = ds_sensor.FindAll(x => x.type.Contains("PYR")); //日照計 + var modelTemplst = ds_sensor.FindAll(x => x.type.Contains("MTR")); //模組溫度計 + var envTemplst = ds_sensor.FindAll(x => x.type.Contains("ETR")); //環境溫度計 + var humlst = ds_sensor.FindAll(x => x.type.Contains("EMM"));//環境濕度計 + var vandlst = ds_sensor.FindAll(x => x.type.Contains("VAN")); //風速計 var dustlst = ds_sensor.FindAll(x => x.type.Contains("DST")); //落塵計 add @ 2021-12-12 var winlst = ds_sensor.FindAll(x => x.type.Contains("WIN")); //風向計 add @ 2021-12-12 var irrDaylst = ds_sensor.FindAll(x => x.type.Contains("TPY")); //累計日照計 add @ 2021-12-12 diff --git a/solarApp/Service/procSyncError.cs b/solarApp/Service/procSyncError.cs index 3a0d189..d22819a 100644 --- a/solarApp/Service/procSyncError.cs +++ b/solarApp/Service/procSyncError.cs @@ -50,7 +50,7 @@ namespace solarApp.Service #endregion - #region 取得 昨天到今天的尚未同步的異常資料 + #region 取得尚未同步的異常資料 sql = $@" select max(id) new_id, (select max(id) old_id from err_main ) old_id from alarmorion_orionalarmrecord "; var ds_max = conn.Query(sql, commandTimeout: 600).AsList(); @@ -145,8 +145,8 @@ namespace solarApp.Service site_id, alarmID, datestamp, HealthStatus from ( select site_id, datestamp, sourceState, id alarmID, - case when alarmClass = 4 then 3 # Network 控制盒斷線 - 紅燈 - when alarmClass != 4 then 2 end HealthStatus # inv, sensor 異常 黃燈 + case when alarmClass = 14 then 3 # Network 控制盒斷線 - 紅燈 + when alarmClass != 14 then 2 end HealthStatus # inv, sensor 異常 黃燈 from err_main where sourceState = 1 and left(site_id , 1) = '0' and datestamp > '{ System.DateTime.Now.AddDays(-60).ToString("yyyy-MM-dd")}' diff --git a/solarApp/fmArchive.cs b/solarApp/fmArchive.cs index f7c4c0a..99f5400 100644 --- a/solarApp/fmArchive.cs +++ b/solarApp/fmArchive.cs @@ -297,8 +297,8 @@ namespace solarApp string date2 = dtSelect2.Value.ToString("yyyy-MM-dd"); procSensorSvc sensorSvc = new procSensorSvc(); procInvSvc invSvc = new procInvSvc(); - procStationSvc siteSvc = new procStationSvc(); - + procStationSvc siteSvc = new procStationSvc(); + foreach (var item in site_list) { //RadioButton rb = new RadioButton(); @@ -306,7 +306,7 @@ namespace solarApp //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")); @@ -556,8 +556,7 @@ namespace solarApp procInvSvc invSvc = new procInvSvc(); procStationSvc siteSvc = new procStationSvc(); - //foreach (var item in site_list) - //{ + sensorSvc.isFirst = true; foreach (DateTime day in EachDay(DateTime.Parse(date1), DateTime.Parse(date2))) { @@ -567,9 +566,8 @@ namespace solarApp invSvc.archiveData(lbSiteID_sensor.Text.Substring(0, 9), day.ToString("yyyy-MM-dd")); siteSvc.archiveData(lbSiteID_sensor.Text.Substring(0, 9), day.ToString("yyyy-MM-dd")); invSvc.report_invDay(lbSiteID_sensor.Text.Substring(0, 9), day.ToString("yyyy-MM-dd")); - } - i++; - //} + } + lbMsgTitle.Text = System.DateTime.Now.ToString() + " 完成!"; }