|
@@ -346,6 +346,8 @@
|
|
|
<if test = "param.beginRate != null "> and tmp.read_rate >= #{param.beginRate}</if>
|
|
|
<if test = "param.endRate != null "> and tmp.read_rate <![CDATA[ <= ]]> #{param.endRate}</if>
|
|
|
<if test = "param.custormerId != null"> and tmp.customer_id = #{param.custormerId}</if>
|
|
|
+ <if test = "param.concentratorId != null">and tmp.concentrator_id = #{param.concentratorId}</if>
|
|
|
+ <if test = "param.deviceTypeId != null" >and tmp.device_type_id = #{param.deviceTypeId}</if>
|
|
|
<if test = "param.concentratorCode != null and param.concentratorCode != '' "> and con.serial_number like #{param.concentratorCode}</if>
|
|
|
</sql>
|
|
|
<!-- 查询抄表率,不含近7天统计 -->
|
|
@@ -372,6 +374,7 @@
|
|
|
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,
|
|
@@ -382,6 +385,7 @@
|
|
|
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,
|
|
@@ -421,10 +425,13 @@
|
|
|
<if test = "param.statDay != null and param.statDay != 0"> and stat_day = #{param.statDay}</if>
|
|
|
GROUP BY
|
|
|
customer_id,
|
|
|
- concentrator_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)
|
|
|
</sql>
|
|
|
<select id="getListByDay" resultType="com.bz.smart_city.dto.StatMeterReadRateDto">
|
|
|
<include refid="base_query_getListByDay" />
|
|
@@ -453,7 +460,8 @@
|
|
|
SELECT
|
|
|
cust.customer_name as customer_name,
|
|
|
con.serial_number as serial_number,
|
|
|
- tmp.device_count as device_count,
|
|
|
+ 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,
|
|
@@ -463,7 +471,8 @@
|
|
|
SELECT
|
|
|
customer_id,
|
|
|
concentrator_id,
|
|
|
- sum( device_count) AS device_count,
|
|
|
+ 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 ,
|
|
@@ -502,10 +511,13 @@
|
|
|
<if test = "param.statDay != null and param.statDay != 0"> and stat_day = #{param.statDay}</if>
|
|
|
GROUP BY
|
|
|
customer_id,
|
|
|
- concentrator_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)
|
|
|
</sql>
|
|
|
<select id="getListBy7Day" resultType="com.bz.smart_city.dto.StatMeterReadRateDto">
|
|
|
<include refid="base_query_getListBy7Day" />
|
|
@@ -534,7 +546,8 @@
|
|
|
SELECT
|
|
|
cust.customer_name as customer_name,
|
|
|
con.serial_number as serial_number,
|
|
|
- tmp.device_count as device_count,
|
|
|
+ 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,
|
|
@@ -544,6 +557,7 @@
|
|
|
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,
|
|
@@ -583,10 +597,13 @@
|
|
|
<if test = "param.statDay != null and param.statDay != 0"> and stat_day = #{param.statDay}</if>
|
|
|
GROUP BY
|
|
|
customer_id,
|
|
|
- concentrator_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)
|
|
|
</sql>
|
|
|
<select id="getListBy15Day" resultType="com.bz.smart_city.dto.StatMeterReadRateDto">
|
|
|
<include refid="base_query_getListBy15Day" />
|
|
@@ -610,7 +627,180 @@
|
|
|
) tmp
|
|
|
ORDER BY read_rate DESC
|
|
|
</select>
|
|
|
-
|
|
|
-
|
|
|
+ <!-- 今日抄表率 -->
|
|
|
+ <sql id="base_query_getListByToday">
|
|
|
+ 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 ,
|
|
|
+ FORMAT( SUM(IF(read_status = 2, 1, 0)) / count(1) * 100, 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 )
|
|
|
+ <!-- 表类型 -->
|
|
|
+ <if test="param.deviceTypeId != null ">
|
|
|
+ and device_type_id = #{param.deviceTypeId}
|
|
|
+ </if>
|
|
|
+ <!-- 数据权限 -->
|
|
|
+ <if test="param.siteId != null and param.siteId != 0 "> and site_id = #{param.siteId} </if>
|
|
|
+ <if test='param.programItems != null and param.programItems.size() != 0' >
|
|
|
+ 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 <foreach collection="param.programItems" item="item" open="(" separator=" or " close=")">
|
|
|
+ (df.dimension_code = #{item.dimensionCode} and df.dimension_value = #{item.dimensionValue})
|
|
|
+ </foreach> ) ud
|
|
|
+ )
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ <if test = "param.statDay != null and param.statDay != 0"> and read_date = #{param.statDay}</if>
|
|
|
+ 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)
|
|
|
+ </sql>
|
|
|
+ <select id="getListByToday" resultType="com.bz.smart_city.dto.StatMeterReadRateDto">
|
|
|
+ <include refid="base_query_getListByToday" />
|
|
|
+ <include refid="where_clause" />
|
|
|
+ <if test="param.sortColumn != null and param.sortColumn != ''">
|
|
|
+ <if test="param.sortOrder != null and param.sortOrder != ''">
|
|
|
+ order by ${param.sortColumn} ${param.sortOrder}
|
|
|
+ </if>
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
+ <select id="summaryListByToday" resultType="com.bz.smart_city.dto.StatMeterReadRateDto">
|
|
|
+ select
|
|
|
+ ifnull(SUM(tmp.device_count),0) as device_count,
|
|
|
+ ifnull(SUM(tmp.read_times),0) as read_times,
|
|
|
+ ifnull(SUM(tmp.real_read_times),0) as real_read_times,
|
|
|
+ ifnull(SUM(tmp.un_read_times),0) as un_read_times,
|
|
|
+ ifnull(FORMAT(SUM(tmp.real_read_times)/SUM(tmp.read_times)*100,2),0) as read_rate
|
|
|
+ from (
|
|
|
+ <include refid="base_query_getListByToday" />
|
|
|
+ <include refid="where_clause"/>
|
|
|
+ ) tmp
|
|
|
+ ORDER BY read_rate DESC
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 按月查询抄表率 -->
|
|
|
+ <sql id="base_query_getListByMonth">
|
|
|
+ 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
|
|
|
+ <!-- 表类型 -->
|
|
|
+ <if test="param.deviceTypeId != null ">
|
|
|
+ and meter_type_id = #{param.deviceTypeId}
|
|
|
+ </if>
|
|
|
+ <!-- 数据权限 -->
|
|
|
+ <if test="param.siteId != null and param.siteId != 0 "> and site_id = #{param.siteId} </if>
|
|
|
+ <if test='param.programItems != null and param.programItems.size() != 0' >
|
|
|
+ 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 <foreach collection="param.programItems" item="item" open="(" separator=" or " close=")">
|
|
|
+ (df.dimension_code = #{item.dimensionCode} and df.dimension_value = #{item.dimensionValue})
|
|
|
+ </foreach> ) ud
|
|
|
+ )
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ <if test = "param.statDay != null and param.statDay != 0"> and stat_month = #{param.statDay}</if>
|
|
|
+ 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)
|
|
|
+ </sql>
|
|
|
+ <select id="getListByMonth" resultType="com.bz.smart_city.dto.StatMeterReadRateDto">
|
|
|
+ <include refid="base_query_getListByMonth" />
|
|
|
+ <include refid="where_clause" />
|
|
|
+ <if test="param.sortColumn != null and param.sortColumn != ''">
|
|
|
+ <if test="param.sortOrder != null and param.sortOrder != ''">
|
|
|
+ order by ${param.sortColumn} ${param.sortOrder}
|
|
|
+ </if>
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
+ <select id="summaryListByMonth" resultType="com.bz.smart_city.dto.StatMeterReadRateDto">
|
|
|
+ select
|
|
|
+ ifnull(SUM(tmp.device_count),0) as device_count,
|
|
|
+ ifnull(SUM(tmp.read_times),0) as read_times,
|
|
|
+ ifnull(SUM(tmp.real_read_times),0) as real_read_times,
|
|
|
+ ifnull(SUM(tmp.un_read_times),0) as un_read_times,
|
|
|
+ ifnull(FORMAT(SUM(tmp.real_read_times)/SUM(tmp.read_times)*100,2),0) as read_rate
|
|
|
+ from (
|
|
|
+ <include refid="base_query_getListByMonth" />
|
|
|
+ <include refid="where_clause"/>
|
|
|
+ ) tmp
|
|
|
+ ORDER BY read_rate DESC
|
|
|
+ </select>
|
|
|
+
|
|
|
</mapper>
|
|
|
|