stat_day,
site_id,
channel_id,
customer_id,
concentrator_id,
collector_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_collector (
stat_day,
site_id,
channel_id,
customer_id,
concentrator_id,
collector_id,
device_count,
read_times,
real_read_times,
un_read_times,
read_rate,
date_create,
date_update
) VALUES (
#{statMeterReadRateByCollector.statDay,jdbcType=INTEGER},
#{statMeterReadRateByCollector.siteId,jdbcType=INTEGER},
#{statMeterReadRateByCollector.channelId,jdbcType=INTEGER},
#{statMeterReadRateByCollector.customerId,jdbcType=INTEGER},
#{statMeterReadRateByCollector.concentratorId,jdbcType=INTEGER},
#{statMeterReadRateByCollector.collectorId,jdbcType=INTEGER},
#{statMeterReadRateByCollector.deviceCount,jdbcType=INTEGER},
#{statMeterReadRateByCollector.readTimes,jdbcType=INTEGER},
#{statMeterReadRateByCollector.realReadTimes,jdbcType=INTEGER},
#{statMeterReadRateByCollector.unReadTimes,jdbcType=INTEGER},
#{statMeterReadRateByCollector.readRate,jdbcType=DECIMAL},
#{statMeterReadRateByCollector.dateCreate,jdbcType=TIMESTAMP},
#{statMeterReadRateByCollector.dateUpdate,jdbcType=TIMESTAMP}
)
INSERT INTO sc_stat_meter_read_rate_by_collector
stat_day, site_id, channel_id, customer_id, concentrator_id, collector_id, device_count, read_times, real_read_times, un_read_times, read_rate, date_create, date_update,
VALUES
#{statMeterReadRateByCollector.statDay,jdbcType=INTEGER},
#{statMeterReadRateByCollector.siteId,jdbcType=INTEGER},
#{statMeterReadRateByCollector.channelId,jdbcType=INTEGER},
#{statMeterReadRateByCollector.customerId,jdbcType=INTEGER},
#{statMeterReadRateByCollector.concentratorId,jdbcType=INTEGER},
#{statMeterReadRateByCollector.collectorId,jdbcType=INTEGER},
#{statMeterReadRateByCollector.deviceCount,jdbcType=INTEGER},
#{statMeterReadRateByCollector.readTimes,jdbcType=INTEGER},
#{statMeterReadRateByCollector.realReadTimes,jdbcType=INTEGER},
#{statMeterReadRateByCollector.unReadTimes,jdbcType=INTEGER},
#{statMeterReadRateByCollector.readRate,jdbcType=DECIMAL},
#{statMeterReadRateByCollector.dateCreate,jdbcType=TIMESTAMP},
#{statMeterReadRateByCollector.dateUpdate,jdbcType=TIMESTAMP},
INSERT INTO sc_stat_meter_read_rate_by_collector (
stat_day,
site_id,
channel_id,
customer_id,
concentrator_id,
collector_id,
device_count,
read_times,
real_read_times,
un_read_times,
read_rate,
date_create,
date_update
)VALUES
(
#{statMeterReadRateByCollector.statDay,jdbcType=INTEGER},
#{statMeterReadRateByCollector.siteId,jdbcType=INTEGER},
#{statMeterReadRateByCollector.channelId,jdbcType=INTEGER},
#{statMeterReadRateByCollector.customerId,jdbcType=INTEGER},
#{statMeterReadRateByCollector.concentratorId,jdbcType=INTEGER},
#{statMeterReadRateByCollector.collectorId,jdbcType=INTEGER},
#{statMeterReadRateByCollector.deviceCount,jdbcType=INTEGER},
#{statMeterReadRateByCollector.readTimes,jdbcType=INTEGER},
#{statMeterReadRateByCollector.realReadTimes,jdbcType=INTEGER},
#{statMeterReadRateByCollector.unReadTimes,jdbcType=INTEGER},
#{statMeterReadRateByCollector.readRate,jdbcType=DECIMAL},
#{statMeterReadRateByCollector.dateCreate,jdbcType=TIMESTAMP},
#{statMeterReadRateByCollector.dateUpdate,jdbcType=TIMESTAMP}
)
UPDATE sc_stat_meter_read_rate_by_collector
site_id= #{statMeterReadRateByCollector.siteId,jdbcType=INTEGER}, channel_id= #{statMeterReadRateByCollector.channelId,jdbcType=INTEGER}, customer_id= #{statMeterReadRateByCollector.customerId,jdbcType=INTEGER}, concentrator_id= #{statMeterReadRateByCollector.concentratorId,jdbcType=INTEGER}, collector_id= #{statMeterReadRateByCollector.collectorId,jdbcType=INTEGER}, device_count= #{statMeterReadRateByCollector.deviceCount,jdbcType=INTEGER}, read_times= #{statMeterReadRateByCollector.readTimes,jdbcType=INTEGER}, real_read_times= #{statMeterReadRateByCollector.realReadTimes,jdbcType=INTEGER}, un_read_times= #{statMeterReadRateByCollector.unReadTimes,jdbcType=INTEGER}, read_rate= #{statMeterReadRateByCollector.readRate,jdbcType=DECIMAL}, date_create= #{statMeterReadRateByCollector.dateCreate,jdbcType=TIMESTAMP}, date_update= #{statMeterReadRateByCollector.dateUpdate,jdbcType=TIMESTAMP}
WHERE stat_day = #{statMeterReadRateByCollector.statDay,jdbcType=INTEGER}
SELECT
cust.customer_name as customer_name,
con.serial_number as serial_number,
col.collector_no as collector_no,
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,
collector_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_collector
WHERE 1 = 1
and meter_type_id = #{param.deviceTypeId}
and site_id = #{param.siteId}
and collector_id IN (
SELECT DISTINCT
rd.collector_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,
collector_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_collector col ON ( tmp.collector_id = col.id )
where 1 = 1
and tmp.read_rate >= #{param.beginRate} and tmp.read_rate #{param.endRate} and tmp.customer_id = #{param.custormerId} and col.collector_no like #{param.collectorCode} and con.serial_number like #{param.concentratorCode}
SELECT
cust.customer_name as customer_name,
con.serial_number as serial_number,
col.collector_no as collector_no,
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,
collector_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_collector
WHERE 1 = 1
and meter_type_id = #{param.deviceTypeId}
and site_id = #{param.siteId}
and collector_id IN (
SELECT DISTINCT
rd.collector_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.statDay}
GROUP BY
customer_id,
concentrator_id,
collector_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_collector col ON ( tmp.collector_id = col.id )
SELECT
cust.customer_name as customer_name,
con.serial_number as serial_number,
col.collector_no as collector_no,
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,
collector_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_collector_7day
WHERE 1 = 1
and meter_type_id = #{param.deviceTypeId}
and site_id = #{param.siteId}
and collector_id IN (
SELECT DISTINCT
rd.collector_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.statDay}
GROUP BY
customer_id,
concentrator_id,
collector_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_collector col ON ( tmp.collector_id = col.id )
SELECT
cust.customer_name as customer_name,
con.serial_number as serial_number,
col.collector_no as collector_no,
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,
collector_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_collector_15day
WHERE 1 = 1
and meter_type_id = #{param.deviceTypeId}
and site_id = #{param.siteId}
and collector_id IN (
SELECT DISTINCT
rd.collector_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.statDay}
GROUP BY
customer_id,
concentrator_id,
collector_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_collector col ON ( tmp.collector_id = col.id )