diff --git a/SolarPower/Properties/launchSettings.json b/SolarPower/Properties/launchSettings.json
index b3dd8ad..83ae215 100644
--- a/SolarPower/Properties/launchSettings.json
+++ b/SolarPower/Properties/launchSettings.json
@@ -21,7 +21,7 @@
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Product",
+ "ASPNETCORE_ENVIRONMENT": "Production",
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
diff --git a/SolarPower/Quartz/Jobs/ExceptionSchedule.cs b/SolarPower/Quartz/Jobs/ExceptionSchedule.cs
index 723f5d4..ae7bc8a 100644
--- a/SolarPower/Quartz/Jobs/ExceptionSchedule.cs
+++ b/SolarPower/Quartz/Jobs/ExceptionSchedule.cs
@@ -46,8 +46,7 @@ namespace SolarPower.Quartz.Jobs
if(ExceptionList.Count > 0 )
{
// 立刻發報
- var ExceptionListex = ExceptionList.Where(x => x.sourceState == 1 &&
- x.priority == 1 ).ToList();
+ var ExceptionListex = ExceptionList.Where(x => x.priority == 1 ).ToList();
// 12小時後發報
var ExceptionListex2 = ExceptionList.Where(x => x.sourceState == 1 &&
x.priority == 2 &&
@@ -78,10 +77,10 @@ namespace SolarPower.Quartz.Jobs
$"異常訊息:{Exception.errMsg}" + "
" +
$"設備編號:{Exception.errDevice}" + "
" +
$"異常編號:{Exception.id}" + "
";
- if (Exception.errMsgT == "d")
- {
- Content += $"當前數值:{Exception.errValue}" + "
";
- }
+ //if (Exception.errMsgT == "d")
+ //{
+ // Content += $"當前數值:{Exception.errValue}" + "
";
+ //}
foreach (var user in UserListWithPowerstation)
{
@@ -98,19 +97,18 @@ namespace SolarPower.Quartz.Jobs
Type = 1,
ExceptionId = Exception.id
};
- //List properties = new List()
- //{
- // "UserId",
- // "EmailType",
- // "RecipientEmail",
- // "Subject",
- // "Content",
- // "RecipientName",
- // "Type",
- // "ExceptionId"
- //};
- //await noticeScheduleRepository.AddOneAsync(DaySchedule, properties);
-
+ List properties = new List()
+ {
+ "UserId",
+ "EmailType",
+ "RecipientEmail",
+ "Subject",
+ "Content",
+ "RecipientName",
+ "Type",
+ "ExceptionId"
+ };
+ await noticeScheduleRepository.AddOneAsync(DaySchedule, properties);
}
var powerstation = await powerStationRepository.GetOneAsync(Exception.PowerStationId);
diff --git a/SolarPower/Repository/Implement/OverviewRepository.cs b/SolarPower/Repository/Implement/OverviewRepository.cs
index e9f5174..876ed87 100644
--- a/SolarPower/Repository/Implement/OverviewRepository.cs
+++ b/SolarPower/Repository/Implement/OverviewRepository.cs
@@ -406,7 +406,7 @@ namespace SolarPower.Repository.Implement
}
- sql += " order by errvalue ";
+ sql += " order by pr.Id ";
result = (await conn.QueryAsync(sql,
new
@@ -434,31 +434,40 @@ namespace SolarPower.Repository.Implement
{
DateTime start;
DateTime end;
- var sql = @$"select pr.FormId as FormId, pr.Id as ErrorID, a.id, site_id, ps.Id PowerStationId, `timestamp`, FROM_UNIXTIME((`timestamp` / 1000), '%Y-%m-%d %H:%i:%s') dev_time ,
- a.sourceState err_status, FROM_UNIXTIME( (a.normalTime / 1000), '%Y-%m-%d %H:%i:%s') normalTime,
- a.alarmClass, b.alarmClass_zh as alarmClassName,ps.Name as PowerStationName, errDevice, err_valueKind, errValue, FROM_UNIXTIME( (a.lastUpdate / 1000), '%Y-%m-%d %H:%i:%s') lastUpdate, c.errMsg_tw cerrMsg_tw, d.errMsg_tw derrMsg_tw,
- case when c.errMsg_tw is null then
- case when err_valueKind = 'b' then d.errMsg_tw
- when err_valueKind = 'd' then CONCAT(d.errMsg_tw, ': ', round(a.errValue, 2))
- when d.errMsg_tw is null then a.errValue
- when a.errValue is null then d.errMsg_tw
- else CONCAT(a.errValue, ', ' , ifNull(d.errMsg_tw, '')) end
- else
- case when err_valueKind = 'b' then c.errMsg_tw
- when err_valueKind = 'd' then CONCAT(c.errMsg_tw, ': ', round(a.errValue, 2))
- when c.errMsg_tw is null then a.errValue
- when a.errValue is null then c.errMsg_tw
- else CONCAT(a.errValue, ', ' , ifNull(c.errMsg_tw, '')) end
- end errMsg
- from err_main a
- join alarmorion_orionalarmclass b on a.alarmclass = b.id
- left join ref_err_device c on trim(b.alarmClass) = c.deviceType
- left join ref_err_inv d on lower(b.alarmClass) = d.deviceType
- # and case when lower(b.alarmClass) = 'inverter' and err_valuekind = 'e' then errvalue else '' end = d.errCode
- and a.errDeviceBrand = d.brend and a.errDeviceModel = d.model and a.errValue = d.errCode
- left join power_station ps on ps.Code = site_id
- left join operation_record pr on pr.ErrorCode = a.id
- WHERE a.sourceState = @Status AND ps.Id IN @PowerStationId";
+ string sql = $@"
+select pr.FormId as FormId, pr.Id as ErrorID, a.id, site_id, ps.Id PowerStationId, `timestamp`, FROM_UNIXTIME((`timestamp` / 1000), '%Y-%m-%d %H:%i:%s') dev_time ,
+ a.sourceState err_status, FROM_UNIXTIME( (a.normalTime / 1000), '%Y-%m-%d %H:%i:%s') normalTime,
+ a.alarmClass, b.alarmClass_zh as alarmClassName,ps.Name as PowerStationName, errDevice, err_valueKind, errValue, FROM_UNIXTIME( (a.lastUpdate / 1000), '%Y-%m-%d %H:%i:%s') lastUpdate, a.errMsg
+ from err_main a
+ join alarmorion_orionalarmclass b on a.alarmclass = b.id
+ left join power_station ps on ps.Code = site_id
+ left join operation_record pr on pr.ErrorCode = a.id
+ WHERE a.sourceState = @Status AND ps.Id IN @PowerStationId";
+ //var sql = @$"select pr.FormId as FormId, pr.Id as ErrorID, a.id, site_id, ps.Id PowerStationId, `timestamp`, FROM_UNIXTIME((`timestamp` / 1000), '%Y-%m-%d %H:%i:%s') dev_time ,
+ // a.sourceState err_status, FROM_UNIXTIME( (a.normalTime / 1000), '%Y-%m-%d %H:%i:%s') normalTime,
+ // a.alarmClass, b.alarmClass_zh as alarmClassName,ps.Name as PowerStationName, errDevice, err_valueKind, errValue, FROM_UNIXTIME( (a.lastUpdate / 1000), '%Y-%m-%d %H:%i:%s') lastUpdate, c.errMsg_tw cerrMsg_tw, d.errMsg_tw derrMsg_tw,
+ // case when c.errMsg_tw is null then
+ // case when err_valueKind = 'b' then d.errMsg_tw
+ // when err_valueKind = 'd' then CONCAT(d.errMsg_tw, ': ', round(a.errValue, 2))
+ // when d.errMsg_tw is null then a.errValue
+ // when a.errValue is null then d.errMsg_tw
+ // else CONCAT(a.errValue, ', ' , ifNull(d.errMsg_tw, '')) end
+ // else
+ // case when err_valueKind = 'b' then c.errMsg_tw
+ // when err_valueKind = 'd' then CONCAT(c.errMsg_tw, ': ', round(a.errValue, 2))
+ // when c.errMsg_tw is null then a.errValue
+ // when a.errValue is null then c.errMsg_tw
+ // else CONCAT(a.errValue, ', ' , ifNull(c.errMsg_tw, '')) end
+ // end errMsg
+ // from err_main a
+ // join alarmorion_orionalarmclass b on a.alarmclass = b.id
+ // left join ref_err_device c on trim(b.alarmClass) = c.deviceType
+ // left join ref_err_inv d on lower(b.alarmClass) = d.deviceType
+ // # and case when lower(b.alarmClass) = 'inverter' and err_valuekind = 'e' then errvalue else '' end = d.errCode
+ // and a.errDeviceBrand = d.brend and a.errDeviceModel = d.model and a.errValue = d.errCode
+ // left join power_station ps on ps.Code = site_id
+ // left join operation_record pr on pr.ErrorCode = a.id
+ // WHERE a.sourceState = @Status AND ps.Id IN @PowerStationId";
if (!string.IsNullOrEmpty(post.Range))
@@ -472,7 +481,7 @@ namespace SolarPower.Repository.Implement
sql += @$" AND `timestamp` BETWEEN {startime * 1000} AND {endtime * 1000}";
}
- sql += " order by errvalue ";
+ sql += " order by pr.Id ";
result = (await conn.QueryAsync(sql,
new
@@ -796,68 +805,53 @@ namespace SolarPower.Repository.Implement
{
try
{
- //var sql = @$"SELECT a.`*`,ns.Id FROM
- // (
- // select a.id, site_id, `timestamp`, FROM_UNIXTIME((`timestamp` / 1000), '%Y-%m-%d %H:%i:%s') dev_time ,
- // a.sourceState err_status, FROM_UNIXTIME( (a.normalTime / 1000), '%Y-%m-%d %H:%i:%s') normalTime,
- // a.alarmClass, b.alarmClass as alarmClassName,ps.Name as PowerStationName,ps.Id as PowerStationId, errDevice, err_valueKind, errValue, FROM_UNIXTIME( (a.lastUpdate / 1000), '%Y-%m-%d %H:%i:%s') lastUpdate, d.errMsg_tw errMsg,
- // case when c.errMsg_tw is null then
- // case when err_valueKind = 'b' then d.errMsg_tw
- // when err_valueKind = 'd' then CONCAT(d.errMsg_tw, ': ', round(a.errValue, 2))
- // when d.errMsg_tw is null then a.errValue
- // when a.errValue is null then d.errMsg_tw
- // else CONCAT(a.errValue, ', ' , ifNull(d.errMsg_tw, '')) end
- // else
- // case when err_valueKind = 'b' then c.errMsg_tw
- // when err_valueKind = 'd' then CONCAT(c.errMsg_tw, ': ', round(a.errValue, 2))
- // when c.errMsg_tw is null then a.errValue
- // when a.errValue is null then c.errMsg_tw
- // else CONCAT(a.errValue, ', ' , ifNull(c.errMsg_tw, '')) end
- // end errMsgT
- // from err_main a
- // join alarmorion_orionalarmclass b on a.alarmclass = b.id
- // left join ref_err_device c on trim(b.alarmClass) = c.deviceType
- // left join ref_err_inv d on lower(b.alarmClass) = d.deviceType
- // # and case when lower(b.alarmClass) = 'inverter' and err_valuekind = 'e' then errvalue else '' end = d.errCode
- // and a.errDeviceBrand = d.brend and a.errDeviceModel = d.model and a.errValue = d.errCode
- // left join power_station ps on ps.Code = site_id
- // left join operation_record pr on pr.ErrorCode = a.id
- // ) a
- // LEFT JOIN
- // notice_schedule ns ON ns.ExceptionId = a.id
- // WHERE ns.Id IS NULL AND a.err_status = 1 AND a.PowerStationId IS NOT null";
- var sql = $@"
- SELECT a.`*`,ns.Id FROM
- (
- select pr.FormId as FormId, pr.Id as ErrorID, priority, a.id, site_id, `timestamp`, a.sourceState,
- FROM_UNIXTIME((`timestamp` / 1000), '%Y-%m-%d %H:%i:%s') dev_time ,
- a.sourceState err_status, FROM_UNIXTIME( (a.normalTime / 1000), '%Y-%m-%d %H:%i:%s') normalTime,
- a.alarmClass, b.alarmClass_zh as alarmClassName,ps.Name as PowerStationName, ps.Id as PowerStationId,errDevice, err_valueKind, errValue,
- FROM_UNIXTIME( (a.lastUpdate / 1000), '%Y-%m-%d %H:%i:%s') lastUpdate, c.errMsg_tw cerrMsg_tw, d.errMsg_tw derrMsg_tw,
- case when c.errMsg_tw is null then
- case when err_valueKind = 'b' then d.errMsg_tw
- when err_valueKind = 'd' then CONCAT(d.errMsg_tw, ': ', round(a.errValue, 2))
- when d.errMsg_tw is null then a.errValue
- when a.errValue is null then d.errMsg_tw
- else CONCAT(a.errValue, ', ' , ifNull(d.errMsg_tw, '')) end
- else
- case when err_valueKind = 'b' then c.errMsg_tw
- when err_valueKind = 'd' then CONCAT(c.errMsg_tw, ': ', round(a.errValue, 2))
- when c.errMsg_tw is null then a.errValue
- when a.errValue is null then c.errMsg_tw
- else CONCAT(a.errValue, ', ' , ifNull(c.errMsg_tw, '')) end
- end errMsg
- #, a.errDeviceBrand , d.brend , a.errDeviceModel, d.model , a.errValue , d.errCode
- from err_main a
- left join alarmorion_orionalarmclass b on a.alarmclass = b.id
- left join ref_err_device c on trim(b.alarmClass) = c.deviceType
- left join ref_err_inv d on lower(b.alarmClass) = d.deviceType
- and a.errDeviceBrand = d.brend and a.errDeviceModel = d.model and a.errValue = d.errCode
- left join power_station ps on ps.`Code` = site_id
- left join operation_record pr on pr.ErrorCode = a.id
- where sourceState = 1 and ps.`Code` is not null and priority < 20
- ) a LEFT JOIN notice_schedule ns ON ns.ExceptionId = a.id
- WHERE ns.Id IS NULL ";
+ string sql = $@"SELECT a.`*`,ns.Id FROM
+ (
+ select pr.FormId as FormId, pr.Id as ErrorID, priority, a.id, site_id, `timestamp`, a.sourceState,
+ FROM_UNIXTIME((`timestamp` / 1000), '%Y-%m-%d %H:%i:%s') dev_time ,
+ a.sourceState err_status, FROM_UNIXTIME( (a.normalTime / 1000), '%Y-%m-%d %H:%i:%s') normalTime,
+ a.alarmClass, b.alarmClass_zh as alarmClassName,ps.Name as PowerStationName, ps.Id as PowerStationId,errDevice, err_valueKind, errValue,
+ FROM_UNIXTIME( (a.lastUpdate / 1000), '%Y-%m-%d %H:%i:%s') lastUpdate, -- c.errMsg_tw cerrMsg_tw, d.errMsg_tw derrMsg_tw,
+ a.errMsg
+ from err_main a
+ left join alarmorion_orionalarmclass b on a.alarmclass = b.id
+ left join power_station ps on ps.`Code` = site_id
+ left join operation_record pr on pr.ErrorCode = a.id
+ where datestamp = '{DateTime.Now.ToString("yyyy-MM-dd")}' and ps.`Code` is not null and priority < 20
+ ) a LEFT JOIN notice_schedule ns ON ns.ExceptionId = a.id
+ WHERE ns.Id IS NULL ";
+ // var sql = $@"
+ // SELECT a.`*`,ns.Id FROM
+ // (
+ //select pr.FormId as FormId, pr.Id as ErrorID, priority, a.id, site_id, `timestamp`, a.sourceState,
+ //FROM_UNIXTIME((`timestamp` / 1000), '%Y-%m-%d %H:%i:%s') dev_time ,
+ // a.sourceState err_status, FROM_UNIXTIME( (a.normalTime / 1000), '%Y-%m-%d %H:%i:%s') normalTime,
+ // a.alarmClass, b.alarmClass_zh as alarmClassName,ps.Name as PowerStationName, ps.Id as PowerStationId,errDevice, err_valueKind, errValue,
+ // FROM_UNIXTIME( (a.lastUpdate / 1000), '%Y-%m-%d %H:%i:%s') lastUpdate, c.errMsg_tw cerrMsg_tw, d.errMsg_tw derrMsg_tw,
+ // case when c.errMsg_tw is null then
+ // case when err_valueKind = 'b' then d.errMsg_tw
+ // when err_valueKind = 'd' then CONCAT(d.errMsg_tw, ': ', round(a.errValue, 2))
+ // when d.errMsg_tw is null then a.errValue
+ // when a.errValue is null then d.errMsg_tw
+ // else CONCAT(a.errValue, ', ' , ifNull(d.errMsg_tw, '')) end
+ // else
+ // case when err_valueKind = 'b' then c.errMsg_tw
+ // when err_valueKind = 'd' then CONCAT(c.errMsg_tw, ': ', round(a.errValue, 2))
+ // when c.errMsg_tw is null then a.errValue
+ // when a.errValue is null then c.errMsg_tw
+ // else CONCAT(a.errValue, ', ' , ifNull(c.errMsg_tw, '')) end
+ // end errMsg
+ // #, a.errDeviceBrand , d.brend , a.errDeviceModel, d.model , a.errValue , d.errCode
+ //from err_main a
+ // left join alarmorion_orionalarmclass b on a.alarmclass = b.id
+ // left join ref_err_device c on trim(b.alarmClass) = c.deviceType
+ // left join ref_err_inv d on lower(b.alarmClass) = d.deviceType
+ // and a.errDeviceBrand = d.brend and a.errDeviceModel = d.model and a.errValue = d.errCode
+ // left join power_station ps on ps.`Code` = site_id
+ // left join operation_record pr on pr.ErrorCode = a.id
+ //where sourceState = 1 and ps.`Code` is not null and priority < 20
+ // ) a LEFT JOIN notice_schedule ns ON ns.ExceptionId = a.id
+ // WHERE ns.Id IS NULL ";
exceptionEmailInfos = (await conn.QueryAsync(sql)).ToList();
}
catch (Exception exception)
diff --git a/SolarPower/Startup.cs b/SolarPower/Startup.cs
index f6eb6c9..cc663aa 100644
--- a/SolarPower/Startup.cs
+++ b/SolarPower/Startup.cs
@@ -120,15 +120,8 @@ namespace SolarPower
services.AddSingleton(
new JobSchedule(jobType: typeof(CalcInverter15minJob), cronExpression: Configuration.GetValue("BackgroundServiceCron:CalcInverter15minJob"))
);
- //#endregion
-
- ////#region pqoqqT(CI5)
- //services.AddSingleton();
- //services.AddSingleton(
- //new JobSchedule(jobType: typeof(CalcPowerStationJob), cronExpression: Configuration.GetValue("BackgroundServiceCron:CalcPowerStationJob"))
- ////new JobSchedule(jobType: typeof(CalcPowerStationJob), cronExpression: "0/10 * * * * ?")
- //);
- ////#endregion
+ //#endregion
+
//#region pqoqqT(CI5)
services.AddSingleton();
diff --git a/solarApp/Service/procSyncError.cs b/solarApp/Service/procSyncError.cs
index fd0bd65..3b0843f 100644
--- a/solarApp/Service/procSyncError.cs
+++ b/solarApp/Service/procSyncError.cs
@@ -220,40 +220,60 @@ namespace solarApp.Service
{
conn.Open();
string sql = $@"SELECT a.`*`,
- case priority when 1 then DATE_ADD(dev_time, INTERVAL 24 HOUR)
- when 2 then DATE_ADD(dev_time, INTERVAL 12 HOUR)
- else dev_time end emailTime
- FROM
- (
- select pr.FormId as FormId, pr.Id as ErrorID, priority, a.id, site_id, `timestamp`, a.sourceState,
- FROM_UNIXTIME((`timestamp` / 1000), '%Y-%m-%d %H:%i:%s') dev_time ,
- a.sourceState err_status, FROM_UNIXTIME( (a.normalTime / 1000), '%Y-%m-%d %H:%i:%s') normalTime,
- a.alarmClass, b.alarmClass_zh as alarmClassName,ps.Name as PowerStationName, ps.Id as PowerStationId,errDevice, err_valueKind, errValue,
- FROM_UNIXTIME( (a.lastUpdate / 1000), '%Y-%m-%d %H:%i:%s') lastUpdate, c.errMsg_tw cerrMsg_tw, d.errMsg_tw derrMsg_tw,
- case when c.errMsg_tw is null then
- case when err_valueKind = 'b' then d.errMsg_tw
- when err_valueKind = 'd' then CONCAT(d.errMsg_tw, ': ', round(a.errValue, 2))
- when d.errMsg_tw is null then a.errValue
- when a.errValue is null then d.errMsg_tw
- else CONCAT(a.errValue, ', ' , ifNull(d.errMsg_tw, '')) end
- else
- case when err_valueKind = 'b' then c.errMsg_tw
- when err_valueKind = 'd' then CONCAT(c.errMsg_tw, ': ', round(a.errValue, 2))
- when c.errMsg_tw is null then a.errValue
- when a.errValue is null then c.errMsg_tw
- else CONCAT(a.errValue, ', ' , ifNull(c.errMsg_tw, '')) end
- end errMsg
- #, a.errDeviceBrand , d.brend , a.errDeviceModel, d.model , a.errValue , d.errCode
- from err_main a
- left join alarmorion_orionalarmclass b on a.alarmclass = b.id
- left join ref_err_device c on trim(b.alarmClass) = c.deviceType
- left join ref_err_inv d on lower(b.alarmClass) = d.deviceType
- and a.errDeviceBrand = d.brend and a.errDeviceModel = d.model and a.errValue = d.errCode
- left join power_station ps on ps.`Code` = site_id
- left join operation_record pr on pr.ErrorCode = a.id
- where sourceState = 1 and datestamp > '{System.DateTime.Now.AddDays(-60).ToString("yyyy-MM-dd")}' and ps.`Code` is not null
- ) a
- order by a.id desc limit 1000";
+ case priority when 1 then dev_time
+ when 2 then DATE_ADD(dev_time, INTERVAL 12 HOUR)
+ when 3 then DATE_ADD(dev_time, INTERVAL 24 HOUR)
+ else dev_time end emailTime
+ FROM
+ (
+ select pr.FormId as FormId, pr.Id as ErrorID, priority, a.id, site_id, `timestamp`, a.sourceState,
+ FROM_UNIXTIME((`timestamp` / 1000), '%Y-%m-%d %H:%i:%s') dev_time ,
+ a.sourceState err_status, FROM_UNIXTIME( (a.normalTime / 1000), '%Y-%m-%d %H:%i:%s') normalTime,
+ a.alarmClass, b.alarmClass_zh as alarmClassName,ps.Name as PowerStationName, ps.Id as PowerStationId,errDevice, err_valueKind, errValue,
+ FROM_UNIXTIME( (a.lastUpdate / 1000), '%Y-%m-%d %H:%i:%s') lastUpdate,
+ a.errMsg
+ from err_main a
+ left join alarmorion_orionalarmclass b on a.alarmclass = b.id
+ left join power_station ps on ps.`Code` = site_id
+ left join operation_record pr on pr.ErrorCode = a.id
+ where sourceState = 1 and datestamp > '{System.DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd")}' and ps.`Code` is not null
+ ) a
+ order by a.id desc limit 1000";
+ // string sql = $@"SELECT a.`*`,
+ // case priority when 1 then DATE_ADD(dev_time, INTERVAL 24 HOUR)
+ // when 2 then DATE_ADD(dev_time, INTERVAL 12 HOUR)
+ // else dev_time end emailTime
+ // FROM
+ // (
+ //select pr.FormId as FormId, pr.Id as ErrorID, priority, a.id, site_id, `timestamp`, a.sourceState,
+ //FROM_UNIXTIME((`timestamp` / 1000), '%Y-%m-%d %H:%i:%s') dev_time ,
+ // a.sourceState err_status, FROM_UNIXTIME( (a.normalTime / 1000), '%Y-%m-%d %H:%i:%s') normalTime,
+ // a.alarmClass, b.alarmClass_zh as alarmClassName,ps.Name as PowerStationName, ps.Id as PowerStationId,errDevice, err_valueKind, errValue,
+ // FROM_UNIXTIME( (a.lastUpdate / 1000), '%Y-%m-%d %H:%i:%s') lastUpdate, c.errMsg_tw cerrMsg_tw, d.errMsg_tw derrMsg_tw,
+ // case when c.errMsg_tw is null then
+ // case when err_valueKind = 'b' then d.errMsg_tw
+ // when err_valueKind = 'd' then CONCAT(d.errMsg_tw, ': ', round(a.errValue, 2))
+ // when d.errMsg_tw is null then a.errValue
+ // when a.errValue is null then d.errMsg_tw
+ // else CONCAT(a.errValue, ', ' , ifNull(d.errMsg_tw, '')) end
+ // else
+ // case when err_valueKind = 'b' then c.errMsg_tw
+ // when err_valueKind = 'd' then CONCAT(c.errMsg_tw, ': ', round(a.errValue, 2))
+ // when c.errMsg_tw is null then a.errValue
+ // when a.errValue is null then c.errMsg_tw
+ // else CONCAT(a.errValue, ', ' , ifNull(c.errMsg_tw, '')) end
+ // end errMsg
+ // #, a.errDeviceBrand , d.brend , a.errDeviceModel, d.model , a.errValue , d.errCode
+ //from err_main a
+ // left join alarmorion_orionalarmclass b on a.alarmclass = b.id
+ // left join ref_err_device c on trim(b.alarmClass) = c.deviceType
+ // left join ref_err_inv d on lower(b.alarmClass) = d.deviceType
+ // and a.errDeviceBrand = d.brend and a.errDeviceModel = d.model and a.errValue = d.errCode
+ // left join power_station ps on ps.`Code` = site_id
+ // left join operation_record pr on pr.ErrorCode = a.id
+ //where sourceState = 1 and datestamp > '{System.DateTime.Now.AddDays(-60).ToString("yyyy-MM-dd")}' and ps.`Code` is not null
+ // ) a
+ // order by a.id desc limit 1000";
List ds = conn.Query(sql, commandTimeout: 600).AsList();
conn.Close();
return ds;