stat_day,
site_id,
channel_id,
customer_id,
concentrator_id,
device_count,
read_times,
real_read_times,
un_read_times,
read_rate,
date_create,
date_update
INSERT INTO sc_stat_meter_read_rate_by_concentrator (
stat_day,
site_id,
channel_id,
customer_id,
concentrator_id,
device_count,
read_times,
real_read_times,
un_read_times,
read_rate,
date_create,
date_update
) VALUES (
#{statMeterReadRateByConcentrator.statDay,jdbcType=INTEGER},
#{statMeterReadRateByConcentrator.siteId,jdbcType=INTEGER},
#{statMeterReadRateByConcentrator.channelId,jdbcType=INTEGER},
#{statMeterReadRateByConcentrator.customerId,jdbcType=INTEGER},
#{statMeterReadRateByConcentrator.concentratorId,jdbcType=INTEGER},
#{statMeterReadRateByConcentrator.deviceCount,jdbcType=INTEGER},
#{statMeterReadRateByConcentrator.readTimes,jdbcType=INTEGER},
#{statMeterReadRateByConcentrator.realReadTimes,jdbcType=INTEGER},
#{statMeterReadRateByConcentrator.unReadTimes,jdbcType=INTEGER},
#{statMeterReadRateByConcentrator.readRate,jdbcType=DECIMAL},
#{statMeterReadRateByConcentrator.dateCreate,jdbcType=TIMESTAMP},
#{statMeterReadRateByConcentrator.dateUpdate,jdbcType=TIMESTAMP}
)
INSERT INTO sc_stat_meter_read_rate_by_concentrator
stat_day, site_id, channel_id, customer_id, concentrator_id, device_count, read_times, real_read_times, un_read_times, read_rate, date_create, date_update,
VALUES
#{statMeterReadRateByConcentrator.statDay,jdbcType=INTEGER},
#{statMeterReadRateByConcentrator.siteId,jdbcType=INTEGER},
#{statMeterReadRateByConcentrator.channelId,jdbcType=INTEGER},
#{statMeterReadRateByConcentrator.customerId,jdbcType=INTEGER},
#{statMeterReadRateByConcentrator.concentratorId,jdbcType=INTEGER},
#{statMeterReadRateByConcentrator.deviceCount,jdbcType=INTEGER},
#{statMeterReadRateByConcentrator.readTimes,jdbcType=INTEGER},
#{statMeterReadRateByConcentrator.realReadTimes,jdbcType=INTEGER},
#{statMeterReadRateByConcentrator.unReadTimes,jdbcType=INTEGER},
#{statMeterReadRateByConcentrator.readRate,jdbcType=DECIMAL},
#{statMeterReadRateByConcentrator.dateCreate,jdbcType=TIMESTAMP},
#{statMeterReadRateByConcentrator.dateUpdate,jdbcType=TIMESTAMP},
INSERT INTO sc_stat_meter_read_rate_by_concentrator (
stat_day,
site_id,
channel_id,
customer_id,
concentrator_id,
device_count,
read_times,
real_read_times,
un_read_times,
read_rate,
date_create,
date_update
)VALUES
(
#{statMeterReadRateByConcentrator.statDay,jdbcType=INTEGER},
#{statMeterReadRateByConcentrator.siteId,jdbcType=INTEGER},
#{statMeterReadRateByConcentrator.channelId,jdbcType=INTEGER},
#{statMeterReadRateByConcentrator.customerId,jdbcType=INTEGER},
#{statMeterReadRateByConcentrator.concentratorId,jdbcType=INTEGER},
#{statMeterReadRateByConcentrator.deviceCount,jdbcType=INTEGER},
#{statMeterReadRateByConcentrator.readTimes,jdbcType=INTEGER},
#{statMeterReadRateByConcentrator.realReadTimes,jdbcType=INTEGER},
#{statMeterReadRateByConcentrator.unReadTimes,jdbcType=INTEGER},
#{statMeterReadRateByConcentrator.readRate,jdbcType=DECIMAL},
#{statMeterReadRateByConcentrator.dateCreate,jdbcType=TIMESTAMP},
#{statMeterReadRateByConcentrator.dateUpdate,jdbcType=TIMESTAMP}
)
UPDATE sc_stat_meter_read_rate_by_concentrator
site_id= #{statMeterReadRateByConcentrator.siteId,jdbcType=INTEGER}, channel_id= #{statMeterReadRateByConcentrator.channelId,jdbcType=INTEGER}, customer_id= #{statMeterReadRateByConcentrator.customerId,jdbcType=INTEGER}, concentrator_id= #{statMeterReadRateByConcentrator.concentratorId,jdbcType=INTEGER}, device_count= #{statMeterReadRateByConcentrator.deviceCount,jdbcType=INTEGER}, read_times= #{statMeterReadRateByConcentrator.readTimes,jdbcType=INTEGER}, real_read_times= #{statMeterReadRateByConcentrator.realReadTimes,jdbcType=INTEGER}, un_read_times= #{statMeterReadRateByConcentrator.unReadTimes,jdbcType=INTEGER}, read_rate= #{statMeterReadRateByConcentrator.readRate,jdbcType=DECIMAL}, date_create= #{statMeterReadRateByConcentrator.dateCreate,jdbcType=TIMESTAMP}, date_update= #{statMeterReadRateByConcentrator.dateUpdate,jdbcType=TIMESTAMP}
WHERE stat_day = #{statMeterReadRateByConcentrator.statDay,jdbcType=INTEGER}
SELECT
cust.customer_name as customer_name,
con.serial_number as serial_number,
tmp.device_count as device_count,
tmp.read_times as read_times,
tmp.real_read_times as real_read_times,
tmp.un_read_times as un_read_times,
tmp.read_rate as read_rate
FROM
(
SELECT
customer_id,
concentrator_id,
sum( device_count) AS device_count,
sum( read_times ) AS read_times,
sum( real_read_times ) AS real_read_times,
sum( un_read_times ) AS un_read_times ,
FORMAT( sum( real_read_times ) / sum( read_times ) * 100, 2 ) AS read_rate
FROM
sc_stat_meter_read_rate_by_concentrator
WHERE 1 = 1
and meter_type_id = #{param.deviceTypeId}
and site_id = #{param.siteId}
and concentrator_id IN (
SELECT DISTINCT
rd.concentrator_id
FROM
sc_water_related_device rd
WHERE
rd.device_id IN (
SELECT
ud.device_id
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
)
)
and stat_day >= #{param.startDate} and stat_day #{param.endDate}
GROUP BY
customer_id,
concentrator_id
) tmp
LEFT JOIN sc_customer cust ON ( tmp.customer_id = cust.id )
LEFT JOIN sc_concentrator con ON ( tmp.concentrator_id = con.id )
where 1 = 1
and tmp.read_rate >= #{param.beginRate} and tmp.read_rate #{param.endRate} and tmp.customer_id = #{param.custormerId}and tmp.concentrator_id = #{param.concentratorId}and tmp.device_type_id = #{param.deviceTypeId} and con.serial_number like #{param.concentratorCode}
SELECT
cust.customer_name as customer_name,
con.serial_number as serial_number,
concat_ws('/',m.name,dt.equipment_type,dt.model) as device_type_name,
tmp.device_count as device_count,
tmp.read_times as read_times,
tmp.real_read_times as real_read_times,
tmp.un_read_times as un_read_times,
tmp.read_rate as read_rate
FROM
(
SELECT
customer_id,
concentrator_id,
meter_type_id as device_type_id,
sum( device_count) AS device_count,
sum( read_times ) AS read_times,
sum( real_read_times ) AS real_read_times,
sum( un_read_times ) AS un_read_times ,
FORMAT( sum( real_read_times ) / sum( read_times ) * 100, 2 ) AS read_rate
FROM
sc_stat_meter_read_rate_by_concentrator
WHERE 1 = 1
and meter_type_id = #{param.deviceTypeId}
and site_id = #{param.siteId}
and customer_id in #{item} and stat_day = #{param.statDay}
GROUP BY
customer_id,
concentrator_id,
device_type_id
) tmp
LEFT JOIN sc_customer cust ON ( tmp.customer_id = cust.id )
LEFT JOIN sc_concentrator con ON ( tmp.concentrator_id = con.id )
left join sc_device_type dt on (tmp.device_type_id = dt.id)
left join sc_device_manufacturer m on (dt.manufacturer_id = m.id)
SELECT
cust.customer_name as customer_name,
con.serial_number as serial_number,
concat_ws('/',m.name,dt.equipment_type,dt.model) as device_type_name,
tmp.device_count as device_count,
tmp.read_times as read_times,
tmp.real_read_times as real_read_times,
tmp.un_read_times as un_read_times,
tmp.read_rate as read_rate
FROM
(
SELECT
customer_id,
concentrator_id,
meter_type_id as device_type_id,
sum( device_count) AS device_count,
sum( read_times ) AS read_times,
sum( real_read_times ) AS real_read_times,
sum( un_read_times ) AS un_read_times ,
FORMAT( sum( real_read_times ) / sum( read_times ) * 100, 2 ) AS read_rate
FROM
sc_stat_meter_read_rate_by_concentrator_7day
WHERE 1 = 1
and meter_type_id = #{param.deviceTypeId}
and site_id = #{param.siteId}
and customer_id in #{item} and stat_day = #{param.statDay}
GROUP BY
customer_id,
concentrator_id,
device_type_id
) tmp
LEFT JOIN sc_customer cust ON ( tmp.customer_id = cust.id )
LEFT JOIN sc_concentrator con ON ( tmp.concentrator_id = con.id )
left join sc_device_type dt on (tmp.device_type_id = dt.id)
left join sc_device_manufacturer m on (dt.manufacturer_id = m.id)
SELECT
cust.customer_name as customer_name,
con.serial_number as serial_number,
concat_ws('/',m.name,dt.equipment_type,dt.model) as device_type_name,
tmp.device_count as device_count,
tmp.read_times as read_times,
tmp.real_read_times as real_read_times,
tmp.un_read_times as un_read_times,
tmp.read_rate as read_rate
FROM
(
SELECT
customer_id,
concentrator_id,
meter_type_id as device_type_id,
sum( device_count) AS device_count,
sum( read_times ) AS read_times,
sum( real_read_times ) AS real_read_times,
sum( un_read_times ) AS un_read_times ,
FORMAT( sum( real_read_times ) / sum( read_times ) * 100, 2 ) AS read_rate
FROM
sc_stat_meter_read_rate_by_concentrator_15day
WHERE 1 = 1
and meter_type_id = #{param.deviceTypeId}
and site_id = #{param.siteId}
and customer_id in #{item} and stat_day = #{param.statDay}
GROUP BY
customer_id,
concentrator_id,
device_type_id
) tmp
LEFT JOIN sc_customer cust ON ( tmp.customer_id = cust.id )
LEFT JOIN sc_concentrator con ON ( tmp.concentrator_id = con.id )
left join sc_device_type dt on (tmp.device_type_id = dt.id)
left join sc_device_manufacturer m on (dt.manufacturer_id = m.id)
SELECT
cust.customer_name as customer_name,
con.serial_number as serial_number,
concat_ws('/',m.name,dt.equipment_type,dt.model) as device_type_name,
tmp.device_count as device_count,
tmp.read_times as read_times,
tmp.real_read_times as real_read_times,
tmp.un_read_times as un_read_times,
tmp.read_rate as read_rate
FROM
(
SELECT
customer_id,
concentrator_id,
device_type_id,
count(1) as device_count,
count(1) AS read_times,
SUM(IF(read_status = 2, 1, 0)) as real_read_times,
SUM(IF(read_status = 1, 1, 0)) as un_read_times ,
convert( SUM(IF(read_status = 2, 1, 0)) / count(1) * 100, decimal(5,2) ) AS read_rate
FROM
sc_meter_read_record
WHERE 1 = 1
and device_type_id IN ( SELECT device_type_id FROM sc_w_meter_type WHERE parent_id = 1 )
and device_type_id = #{param.deviceTypeId}
and site_id = #{param.siteId}
and customer_id in #{item} and read_date = #{param.statDay}
GROUP BY
customer_id,
concentrator_id,
device_type_id
) tmp
LEFT JOIN sc_customer cust ON ( tmp.customer_id = cust.id )
LEFT JOIN sc_concentrator con ON ( tmp.concentrator_id = con.id )
left join sc_device_type dt on (tmp.device_type_id = dt.id)
left join sc_device_manufacturer m on (dt.manufacturer_id = m.id)
SELECT
cust.customer_name as customer_name,
con.serial_number as serial_number,
concat_ws('/',m.name,dt.equipment_type,dt.model) as device_type_name,
tmp.device_count as device_count,
tmp.read_times as read_times,
tmp.real_read_times as real_read_times,
tmp.un_read_times as un_read_times,
tmp.read_rate as read_rate
FROM
(
SELECT
customer_id,
concentrator_id,
meter_type_id as device_type_id,
sum( device_count) AS device_count,
sum( read_times ) AS read_times,
sum( real_read_times ) AS real_read_times,
sum( un_read_times ) AS un_read_times ,
FORMAT( sum( real_read_times ) / sum( read_times ) * 100, 2 ) AS read_rate
FROM
sc_stat_meter_read_rate_by_concentrator_month
WHERE 1 = 1
and meter_type_id = #{param.deviceTypeId}
and site_id = #{param.siteId}
and customer_id in #{item} and stat_month = #{param.statDay}
GROUP BY
customer_id,
concentrator_id,
device_type_id
) tmp
LEFT JOIN sc_customer cust ON ( tmp.customer_id = cust.id )
LEFT JOIN sc_concentrator con ON ( tmp.concentrator_id = con.id )
left join sc_device_type dt on (tmp.device_type_id = dt.id)
left join sc_device_manufacturer m on (dt.manufacturer_id = m.id)