發佈版本 0907
This commit is contained in:
parent
e1777eca17
commit
f614fd07f0
@ -21,7 +21,7 @@
|
|||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"launchBrowser": true,
|
"launchBrowser": true,
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Product",
|
"ASPNETCORE_ENVIRONMENT": "Production",
|
||||||
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation"
|
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation"
|
||||||
},
|
},
|
||||||
"applicationUrl": "https://localhost:5001;http://localhost:5000"
|
"applicationUrl": "https://localhost:5001;http://localhost:5000"
|
||||||
|
|||||||
@ -46,8 +46,7 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
if(ExceptionList.Count > 0 )
|
if(ExceptionList.Count > 0 )
|
||||||
{
|
{
|
||||||
// 立刻發報
|
// 立刻發報
|
||||||
var ExceptionListex = ExceptionList.Where(x => x.sourceState == 1 &&
|
var ExceptionListex = ExceptionList.Where(x => x.priority == 1 ).ToList();
|
||||||
x.priority == 1 ).ToList();
|
|
||||||
// 12小時後發報
|
// 12小時後發報
|
||||||
var ExceptionListex2 = ExceptionList.Where(x => x.sourceState == 1 &&
|
var ExceptionListex2 = ExceptionList.Where(x => x.sourceState == 1 &&
|
||||||
x.priority == 2 &&
|
x.priority == 2 &&
|
||||||
@ -78,10 +77,10 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
$"異常訊息:{Exception.errMsg}" + "<br>" +
|
$"異常訊息:{Exception.errMsg}" + "<br>" +
|
||||||
$"設備編號:{Exception.errDevice}" + "<br>" +
|
$"設備編號:{Exception.errDevice}" + "<br>" +
|
||||||
$"異常編號:{Exception.id}" + "<br>";
|
$"異常編號:{Exception.id}" + "<br>";
|
||||||
if (Exception.errMsgT == "d")
|
//if (Exception.errMsgT == "d")
|
||||||
{
|
//{
|
||||||
Content += $"當前數值:{Exception.errValue}" + "<br>";
|
// Content += $"當前數值:{Exception.errValue}" + "<br>";
|
||||||
}
|
//}
|
||||||
|
|
||||||
foreach (var user in UserListWithPowerstation)
|
foreach (var user in UserListWithPowerstation)
|
||||||
{
|
{
|
||||||
@ -98,19 +97,18 @@ namespace SolarPower.Quartz.Jobs
|
|||||||
Type = 1,
|
Type = 1,
|
||||||
ExceptionId = Exception.id
|
ExceptionId = Exception.id
|
||||||
};
|
};
|
||||||
//List<string> properties = new List<string>()
|
List<string> properties = new List<string>()
|
||||||
//{
|
{
|
||||||
// "UserId",
|
"UserId",
|
||||||
// "EmailType",
|
"EmailType",
|
||||||
// "RecipientEmail",
|
"RecipientEmail",
|
||||||
// "Subject",
|
"Subject",
|
||||||
// "Content",
|
"Content",
|
||||||
// "RecipientName",
|
"RecipientName",
|
||||||
// "Type",
|
"Type",
|
||||||
// "ExceptionId"
|
"ExceptionId"
|
||||||
//};
|
};
|
||||||
//await noticeScheduleRepository.AddOneAsync(DaySchedule, properties);
|
await noticeScheduleRepository.AddOneAsync(DaySchedule, properties);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var powerstation = await powerStationRepository.GetOneAsync(Exception.PowerStationId);
|
var powerstation = await powerStationRepository.GetOneAsync(Exception.PowerStationId);
|
||||||
|
|||||||
@ -406,7 +406,7 @@ namespace SolarPower.Repository.Implement
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sql += " order by errvalue ";
|
sql += " order by pr.Id ";
|
||||||
|
|
||||||
result = (await conn.QueryAsync<ExceptionDataTable>(sql,
|
result = (await conn.QueryAsync<ExceptionDataTable>(sql,
|
||||||
new
|
new
|
||||||
@ -434,31 +434,40 @@ namespace SolarPower.Repository.Implement
|
|||||||
{
|
{
|
||||||
DateTime start;
|
DateTime start;
|
||||||
DateTime end;
|
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 ,
|
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.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,
|
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
|
||||||
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
|
from err_main a
|
||||||
join alarmorion_orionalarmclass b on a.alarmclass = b.id
|
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 power_station ps on ps.Code = site_id
|
||||||
left join operation_record pr on pr.ErrorCode = a.id
|
left join operation_record pr on pr.ErrorCode = a.id
|
||||||
WHERE a.sourceState = @Status AND ps.Id IN @PowerStationId";
|
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))
|
if (!string.IsNullOrEmpty(post.Range))
|
||||||
@ -472,7 +481,7 @@ namespace SolarPower.Repository.Implement
|
|||||||
sql += @$" AND `timestamp` BETWEEN {startime * 1000} AND {endtime * 1000}";
|
sql += @$" AND `timestamp` BETWEEN {startime * 1000} AND {endtime * 1000}";
|
||||||
}
|
}
|
||||||
|
|
||||||
sql += " order by errvalue ";
|
sql += " order by pr.Id ";
|
||||||
|
|
||||||
result = (await conn.QueryAsync<ExceptionDataTable>(sql,
|
result = (await conn.QueryAsync<ExceptionDataTable>(sql,
|
||||||
new
|
new
|
||||||
@ -796,11 +805,29 @@ namespace SolarPower.Repository.Implement
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//var sql = @$"SELECT a.`*`,ns.Id FROM
|
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 a.id, site_id, `timestamp`, FROM_UNIXTIME((`timestamp` / 1000), '%Y-%m-%d %H:%i:%s') dev_time ,
|
//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.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,
|
// 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 c.errMsg_tw is null then
|
||||||
// case when err_valueKind = 'b' then d.errMsg_tw
|
// case when err_valueKind = 'b' then d.errMsg_tw
|
||||||
// when err_valueKind = 'd' then CONCAT(d.errMsg_tw, ': ', round(a.errValue, 2))
|
// when err_valueKind = 'd' then CONCAT(d.errMsg_tw, ': ', round(a.errValue, 2))
|
||||||
@ -813,51 +840,18 @@ namespace SolarPower.Repository.Implement
|
|||||||
// when c.errMsg_tw is null then a.errValue
|
// when c.errMsg_tw is null then a.errValue
|
||||||
// when a.errValue is null then c.errMsg_tw
|
// when a.errValue is null then c.errMsg_tw
|
||||||
// else CONCAT(a.errValue, ', ' , ifNull(c.errMsg_tw, '')) end
|
// else CONCAT(a.errValue, ', ' , ifNull(c.errMsg_tw, '')) end
|
||||||
// end errMsgT
|
// end errMsg
|
||||||
|
// #, a.errDeviceBrand , d.brend , a.errDeviceModel, d.model , a.errValue , d.errCode
|
||||||
//from err_main a
|
//from err_main a
|
||||||
// join alarmorion_orionalarmclass b on a.alarmclass = b.id
|
// 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_device c on trim(b.alarmClass) = c.deviceType
|
||||||
// left join ref_err_inv d on lower(b.alarmClass) = d.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
|
// 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 power_station ps on ps.`Code` = site_id
|
||||||
// left join operation_record pr on pr.ErrorCode = a.id
|
// left join operation_record pr on pr.ErrorCode = a.id
|
||||||
// ) a
|
//where sourceState = 1 and ps.`Code` is not null and priority < 20
|
||||||
// LEFT JOIN
|
// ) a LEFT JOIN notice_schedule ns ON ns.ExceptionId = a.id
|
||||||
// notice_schedule ns ON ns.ExceptionId = a.id
|
// WHERE ns.Id IS NULL ";
|
||||||
// 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 ";
|
|
||||||
exceptionEmailInfos = (await conn.QueryAsync<ExceptionEmailInfo>(sql)).ToList();
|
exceptionEmailInfos = (await conn.QueryAsync<ExceptionEmailInfo>(sql)).ToList();
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
|
|||||||
@ -122,13 +122,6 @@ namespace SolarPower
|
|||||||
);
|
);
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
////#region 計算電站發電量等資訊(每整點5分執行)
|
|
||||||
//services.AddSingleton<CalcPowerStationJob>();
|
|
||||||
//services.AddSingleton(
|
|
||||||
//new JobSchedule(jobType: typeof(CalcPowerStationJob), cronExpression: Configuration.GetValue<string>("BackgroundServiceCron:CalcPowerStationJob"))
|
|
||||||
////new JobSchedule(jobType: typeof(CalcPowerStationJob), cronExpression: "0/10 * * * * ?")
|
|
||||||
//);
|
|
||||||
////#endregion
|
|
||||||
|
|
||||||
//#region 計算電站發電量等資訊(每整點5分執行)
|
//#region 計算電站發電量等資訊(每整點5分執行)
|
||||||
services.AddSingleton<CalcPowerStationJobV2>();
|
services.AddSingleton<CalcPowerStationJobV2>();
|
||||||
|
|||||||
@ -220,8 +220,9 @@ namespace solarApp.Service
|
|||||||
{
|
{
|
||||||
conn.Open();
|
conn.Open();
|
||||||
string sql = $@"SELECT a.`*`,
|
string sql = $@"SELECT a.`*`,
|
||||||
case priority when 1 then DATE_ADD(dev_time, INTERVAL 24 HOUR)
|
case priority when 1 then dev_time
|
||||||
when 2 then DATE_ADD(dev_time, INTERVAL 12 HOUR)
|
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
|
else dev_time end emailTime
|
||||||
FROM
|
FROM
|
||||||
(
|
(
|
||||||
@ -229,31 +230,50 @@ namespace solarApp.Service
|
|||||||
FROM_UNIXTIME((`timestamp` / 1000), '%Y-%m-%d %H:%i:%s') dev_time ,
|
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.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,
|
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,
|
FROM_UNIXTIME( (a.lastUpdate / 1000), '%Y-%m-%d %H:%i:%s') lastUpdate,
|
||||||
case when c.errMsg_tw is null then
|
a.errMsg
|
||||||
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
|
from err_main a
|
||||||
left join alarmorion_orionalarmclass b on a.alarmclass = b.id
|
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 power_station ps on ps.`Code` = site_id
|
||||||
left join operation_record pr on pr.ErrorCode = a.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
|
where sourceState = 1 and datestamp > '{System.DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd")}' and ps.`Code` is not null
|
||||||
) a
|
) a
|
||||||
order by a.id desc limit 1000";
|
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<ExceptionEmailInfo> ds = conn.Query<ExceptionEmailInfo>(sql, commandTimeout: 600).AsList<ExceptionEmailInfo>();
|
List<ExceptionEmailInfo> ds = conn.Query<ExceptionEmailInfo>(sql, commandTimeout: 600).AsList<ExceptionEmailInfo>();
|
||||||
conn.Close();
|
conn.Close();
|
||||||
return ds;
|
return ds;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user