1=1
and t1.stat_day = #{params.statDay}
and t1.site_id = #{params.siteId}
and t1.sys_id = #{params.sysId}
and t1.building_id = #{params.buildingId}
and t1.building_id != 0
and t1.floor = #{params.floor}
and t1.alarm_category = #{params.alarmCategory}
and t1.alarm_type = #{params.alarmType}
and t1.handle_status = #{params.handleStatus}
and t1.stat_day >= #{params.startDate}
and t1.stat_day < #{params.endDate}
1=1
and t1.stat_day = #{params.statDay}
and t1.site_id = #{params.siteId}
and t1.sys_id = #{params.sysId}
and t1.building_id = #{params.buildingId}
and t1.floor = #{params.floor}
and t1.alarm_category = #{params.alarmCategory}
and t1.alarm_type = #{params.alarmType}
and t1.handle_status = #{params.handleStatus}
and t1.alarm_time > #{params.startDate}
and t1.alarm_time < #{params.endDate}
and t1.sys_id in
#{sysId}
and t1.site_id in
#{site.id}
SELECT
t1.stat_day as statDay,
t1.site_id as siteId,
t4.`name` as siteName,
t1.sys_id as sysId,
t2.channel_name as sysName,
t1.building_id as buildingId,
t3.`name` as buildingName,
t1.alarm_type as alarmTypeCode,
t5.`name` as alarmTypeName,
t1.alarm_category as alarmCategoryCode,
t6.config_name as alarmCategoryName,
t1.floor as floor,
t1.handle_status as handlStatus,
t7.config_name as handleStatusName,
t1.alarm_times as alarmTimes,
t1.alarm_device_num as alarmDeviceNumber
FROM
sc_stat_device_error_day t1
LEFT JOIN sc_channel t2 ON ( t1.sys_id = t2.id )
LEFT JOIN sc_building t3 ON ( t1.building_id = t3.id )
LEFT JOIN sc_site t4 ON ( t1.site_id = t4.id )
LEFT JOIN sc_alarm_type t5 ON ( t1.alarm_type = t5.id )
LEFT JOIN sc_config_t t6 ON ( t1.alarm_category = t6.config_value AND t6.parent_id = 4)
LEFT JOIN sc_config_t t7 ON ( t1.handle_status = t7.config_value AND t7.parent_id = 1)
${params.orderBy}
limit #{offset}, #{limit}
SELECT
t1.stat_day as statDay,
t1.site_id as siteId,
t4.`name` as siteName,
t1.sys_id as sysId,
t2.channel_name as sysName,
t1.building_id as buildingId,
t3.`name` as buildingName,
t1.alarm_type as alarmTypeCode,
t5.`name` as alarmTypeName,
t1.alarm_category as alarmCategoryCode,
t6.config_name as alarmCategoryName,
t1.floor as floor,
t1.handle_status as handlStatus,
t7.config_name as handleStatusName,
t1.alarm_times as alarmTimes,
t1.alarm_device_num as alarmDeviceNumber
FROM
sc_stat_device_error_7day t1
LEFT JOIN sc_channel t2 ON ( t1.sys_id = t2.id )
LEFT JOIN sc_building t3 ON ( t1.building_id = t3.id )
LEFT JOIN sc_site t4 ON ( t1.site_id = t4.id )
LEFT JOIN sc_alarm_type t5 ON ( t1.alarm_type = t5.id )
LEFT JOIN sc_config_t t6 ON ( t1.alarm_category = t6.config_value AND t6.parent_id = 4)
LEFT JOIN sc_config_t t7 ON ( t1.handle_status = t7.config_value AND t7.parent_id = 1)
${params.orderBy}
limit #{offset}, #{limit}
SELECT
t1.stat_day as statDay,
t1.site_id as siteId,
t4.`name` as siteName,
t1.sys_id as sysId,
t2.channel_name as sysName,
t1.building_id as buildingId,
t3.`name` as buildingName,
t1.alarm_type as alarmTypeCode,
t5.`name` as alarmTypeName,
t1.alarm_category as alarmCategoryCode,
t6.config_name as alarmCategoryName,
t1.floor as floor,
t1.handle_status as handlStatus,
t7.config_name as handleStatusName,
t1.alarm_times as alarmTimes,
t1.alarm_device_num as alarmDeviceNumber
FROM
sc_stat_device_error_30day t1
LEFT JOIN sc_channel t2 ON ( t1.sys_id = t2.id )
LEFT JOIN sc_building t3 ON ( t1.building_id = t3.id )
LEFT JOIN sc_site t4 ON ( t1.site_id = t4.id )
LEFT JOIN sc_alarm_type t5 ON ( t1.alarm_type = t5.id )
LEFT JOIN sc_config_t t6 ON ( t1.alarm_category = t6.config_value AND t6.parent_id = 4)
LEFT JOIN sc_config_t t7 ON ( t1.handle_status = t7.config_value AND t7.parent_id = 1)
${params.orderBy}
limit #{offset}, #{limit}
SELECT
t1.building_id as buildingId,
t2.name as buildingName,
count(1) as alarmTimes
FROM
sc_device_error t1
LEFT JOIN sc_building t2 ON ( t1.building_id = t2.id)
left join sc_device_dimension sdd on (sdd.device_id = t1.device_id and sdd.status = 1)
and t1.status = 1 and t1.sys_id != -99
and
sdd.${item.dimensionCode} = #{item.dimensionValue}
GROUP BY t1.building_id
${params.orderBy}
limit #{offset}, #{limit}
SELECT
DATE_FORMAT(t1.alarm_time,'%Y%m%d') as statDay,
t1.alarm_category as alarmCategoryCode,
t2.config_name as alarmCategoryName,
count( 1 ) as alarmTimes
FROM
sc_device_error t1
LEFT JOIN sc_config_t t2 ON ( t1.alarm_category = t2.config_value AND t2.parent_id = 4 )
and t1.status = 1
and EXISTS (
select 1 from
(select
distinct df.device_id
FROM sc_device_dim_info df
WHERE 1 = 1
and
(df.dimension_code = #{item.dimensionCode} and df.dimension_value = #{item.dimensionValue})
) ud WHERE ud.device_id = t1.device_id)
GROUP BY
DATE_FORMAT(t1.alarm_time,'%Y%m%d'),t1.alarm_category,t2.config_name
SELECT
t1.alarm_category as alarmCategoryCode,
t2.config_name as alarmCategoryName,
count( 1 ) as alarmTimes
FROM
sc_device_error t1
LEFT JOIN sc_config_t t2 ON ( t1.alarm_category = t2.config_value AND t2.parent_id = 4 )
and t1.status = 1
GROUP BY
t1.alarm_category,t2.config_name
SELECT
t1.handle_status as handlStatus,
t2.config_name as handleStatusName,
count(1) as alarmDeviceNumber
FROM
sc_device_error t1
LEFT JOIN sc_config_t t2 ON ( t1.handle_status = t2.config_value AND t2.parent_id = 1 )
left join sc_device_dimension sdd on (sdd.device_id = t1.device_id and sdd.status = 1)
and t1.status = 1
and
sdd.${item.dimensionCode} = #{item.dimensionValue}
GROUP BY
t1.handle_status,t2.config_name
SELECT
t1.alarm_type_id AS alarmTypeCode,
t2.`name` AS alarmTypeName,
count(1) as alarmDeviceNumber
FROM
sc_device_error t1
LEFT JOIN sc_alarm_type t2 ON ( t1.alarm_type_id = t2.id )
left join sc_device_dimension sdd on (sdd.device_id = t1.device_id and sdd.status = 1)
and t1.status = 1
and
sdd.${item.dimensionCode} = #{item.dimensionValue}
GROUP BY
t1.alarm_type_id,t2.`name`
SELECT
t1.device_status as statusCode,
t2.config_name as statusName,
COUNT(t1.device_no) as numberOfDevice
FROM
sc_device t1
LEFT JOIN sc_config_t t2 ON ( t1.device_status = t2.config_value AND t2.parent_id = 7 )
left join sc_device_dimension sdd on (sdd.device_id = t1.id and sdd.status = 1)
and
sdd.${item.dimensionCode} = #{item.dimensionValue}
and t1.sys_id != -99
and t1.status = 1
and t1.building_id is not null
GROUP BY t1.device_status,t2.config_name
SELECT
t1.handle_type as handleTypeCode,
t2.config_name as handleTypeName,
count(DISTINCT t1.device_id) as numberOfDevice
FROM
sc_device_error_handle t1
LEFT JOIN sc_config_t t2 on(t1.handle_type = t2.config_value and t2.parent_id = 13 )
and t1.status = 1
GROUP BY t1.handle_type, t2.config_name
SELECT
count(1) as times,
count(distinct t1.device_no) as count,
t1.handle_status as is_handle_value,
t2.config_name as is_handle_name
FROM
sc_device_error t1
LEFT JOIN sc_config_t t2 ON ( t1.handle_status = t2.config_value AND t2.parent_id = 1 )
and t1.`status` = 1
group by t1.handle_status, t2.config_name
SELECT
count( 1 ) AS times,
count( DISTINCT t1.device_no ) AS count,
t1.handle_status AS is_hanlde_value,
t2.config_name AS is_handle_name
FROM
sc_device_error t1
LEFT JOIN sc_config_t t2 ON ( t1.handle_status = t2.config_value AND t2.parent_id = 1 )
and t1.`status` = 1
and EXISTS (
select 1 from
(select
distinct df.device_id
FROM sc_device_dim_info df
WHERE 1 = 1
and
(df.dimension_code = #{item.dimensionCode} and df.dimension_value = #{item.dimensionValue})
) ud WHERE ud.device_id = t1.device_id)
GROUP BY
t1.handle_status,
t2.config_name
SELECT
count(1) as total ,
t1.device_type as device_type_id,
dt.equipment_type as device_type_name,
SUM(IF(t1.device_status = 1, 1, 0)) as normal_count,
SUM(IF(t1.device_status != 1, 1, 0)) as abnormal_count,
SUM(IF(t1.device_status = 2, 1, 0)) as fault_count,
SUM(IF(t1.device_status = 4, 1, 0)) as early_warning_count,
SUM(IF(t1.device_status = 5, 1, 0)) as not_enabled_count
FROM
sc_device t1
left join sc_device_type dt on (t1.device_type = dt.id and dt.`status` = 1)
WHERE
t1.`status` = 1
GROUP BY
t1.device_type,dt.equipment_type
SELECT
count(1) as total ,
t1.device_type as device_type_id,
dt.equipment_type as device_type_name,
SUM(IF(t1.device_status = 1, 1, 0)) as normal_count,
SUM(IF(t1.device_status != 1, 1, 0)) as abnormal_count,
SUM(IF(t1.device_status = 2, 1, 0)) as fault_count,
SUM(IF(t1.device_status = 4, 1, 0)) as early_warning_count,
SUM(IF(t1.device_status = 5, 1, 0)) as not_enabled_count
FROM
sc_device t1
left join sc_device_type dt on (t1.device_type = dt.id and dt.`status` = 1)
left join sc_device_dimension sdd on (sdd.device_id = t1.id and sdd.status = 1)
and t1.sys_id != -99
and t1.`status` = 1
and
sdd.${item.dimensionCode} = #{item.dimensionValue}
GROUP BY
t1.device_type,dt.equipment_type
select
count(distinct t1.device_no) as number_of_alarm_device,
count(1) as alarm_times,
t2.name as alarm_type_name
FROM
sc_device_error t1
left join sc_alarm_type t2 on (t1.alarm_type_id = t2.id)
and t1.`status` = 1
GROUP BY alarm_type_name
order by alarm_times desc
SELECT
sum( number_of_alarm_device ) as number_of_alarm_device,
sum( alarm_times ) AS alarm_times,
t2.`name` as alarm_type_name
FROM
(
SELECT
count( DISTINCT t1.device_no ) AS number_of_alarm_device,
count( 1 ) AS alarm_times,
t1.alarm_type_id
FROM
sc_device_error t1 FORCE INDEX ( alarm_time )
and t1.`status` = 1
and t1.building_id in #{item}
GROUP BY
t1.alarm_type_id
) tmp
LEFT JOIN sc_alarm_type t2 ON ( tmp.alarm_type_id = t2.id )
GROUP BY
t2.`name`
ORDER BY
alarm_times DESC
SELECT
DATE_FORMAT(t1.alarm_time,'%Y%m%d') as stat_date,
t1.alarm_category as alarm_category_code,
t2.config_name as alarm_category_name,
count( 1 ) as alarm_times
FROM
sc_device_error t1
LEFT JOIN sc_config_t t2 ON ( t1.alarm_category = t2.config_value AND t2.parent_id = 4 )
and t1.status = 1
GROUP BY
DATE_FORMAT(t1.alarm_time,'%Y%m%d'),t1.alarm_category,t2.config_name
order by stat_date asc
SELECT
stat_date as stat_date,
alarm_category as alarm_category_code,
t2.config_name as alarm_category_name,
alarm_times
FROM
(
SELECT
DATE_FORMAT( t1.alarm_time, '%Y%m%d' ) AS stat_date,
t1.alarm_category,
count( 1 ) AS alarm_times
FROM
sc_device_error t1 FORCE INDEX ( alarm_time )
and t1.status = 1
and t1.building_id in #{item}
GROUP BY
DATE_FORMAT( t1.alarm_time, '%Y%m%d' ),
t1.alarm_category
) tmp
LEFT JOIN sc_config_t t2 ON ( tmp.alarm_category = t2.config_value AND t2.parent_id = 4 )
ORDER BY
stat_date ASC
SELECT
DATE_FORMAT( t1.alarm_time, '%Y%m%d' ) as stat_date,
count( 1 ) as total_alarm_times,
SUM(IF(t1.`handle_status` = 1, 1, 0)) as handled_alarm_times,
SUM(IF(t1.`handle_status` = 2, 1, 0)) as unhandle_alarm_times,
CONCAT(FORMAT(SUM(IF(t1.`handle_status` = 2, 1, 0))/ COUNT(1)*100, 2), '%') as unhandle_percentage,
CONCAT(FORMAT(SUM(IF(t1.`handle_status` = 1, 1, 0))/ COUNT(1)*100, 2), '%') as handled_percentage
FROM
sc_device_error t1
AND t1.STATUS = 1
GROUP BY
DATE_FORMAT( t1.alarm_time, '%Y%m%d' )
order by stat_date asc
SELECT
DATE_FORMAT( t1.alarm_time, '%Y%m%d' ) as stat_date,
count( 1 ) as total_alarm_times,
SUM(IF(t1.`handle_status` = 1, 1, 0)) as handled_alarm_times,
SUM(IF(t1.`handle_status` = 2, 1, 0)) as unhandle_alarm_times,
CONCAT(FORMAT(SUM(IF(t1.`handle_status` = 2, 1, 0))/ COUNT(1)*100, 2), '%') as unhandle_percentage,
CONCAT(FORMAT(SUM(IF(t1.`handle_status` = 1, 1, 0))/ COUNT(1)*100, 2), '%') as handled_percentage
FROM
sc_device_error t1
AND t1.STATUS = 1
and t1.building_id in #{item}
GROUP BY
DATE_FORMAT( t1.alarm_time, '%Y%m%d' )
order by stat_date asc