| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.ycl.mapper.unlawful.UnlawfulMapper"> |
| | | <!-- 获取总数--> |
| | | <!-- 获取总数--> |
| | | <select id="getTotal" resultType="java.lang.Integer"> |
| | | SELECT |
| | | count(*) |
| | | FROM |
| | | `ums_base_case` AS ubc |
| | | JOIN ums_violations AS uv ON ubc.id = uv.id |
| | | LEFT JOIN ums_data_dictionary AS t3 ON uv.category_id = t3.id |
| | | LEFT JOIN ums_data_dictionary AS t4 ON uv.type_id = t4.id |
| | | LEFT JOIN ums_sccg_region t5 ON ubc.street_id = t5.id |
| | | WHERE |
| | | ubc.category = 1 |
| | | AND t4.`name` IS NOT NULL |
| | | </select> |
| | | SELECT count(*) |
| | | FROM `ums_base_case` AS ubc |
| | | JOIN ums_violations AS uv ON ubc.id = uv.id |
| | | <if test="type==true"> |
| | | INNER JOIN ums_data_dictionary AS t4 ON uv.grade_id = t4.id |
| | | </if> |
| | | <if test="street==true"> |
| | | INNER JOIN ums_sccg_region r on ubc.street_id = r.id |
| | | </if> |
| | | <if test="video==true"> |
| | | INNER JOIN ums_video_point v on uv.video_point_id = v.id |
| | | </if> |
| | | WHERE ubc.category = 1 |
| | | |
| | | <!-- 按照违规类型统计--> |
| | | <select id="getDataByType" resultType="com.ycl.dto.statistics.CategoryDto"> |
| | | SELECT |
| | | t4.id id, |
| | | t4.NAME name |
| | | FROM |
| | | `ums_base_case` AS ubc |
| | | JOIN ums_violations AS uv ON ubc.id = uv.id |
| | | LEFT JOIN ums_data_dictionary AS t3 ON uv.category_id = t3.id |
| | | LEFT JOIN ums_data_dictionary AS t4 ON uv.type_id = t4.id |
| | | LEFT JOIN ums_sccg_region t5 ON ubc.street_id = t5.id |
| | | WHERE |
| | | ubc.category =1 |
| | | and t4.`name` is NOT NULL |
| | | <if test="startTime !='' and endTime !='' and startTime!=null and endTime !=null"> |
| | | and ubc.create_time between #{startTime} and #{endTime} |
| | | </if> |
| | | group by |
| | | t4.id |
| | | limit #{currentPage}, #{pageSize} |
| | | </select> |
| | | <select id="getStatusDataByType" resultType="com.ycl.dto.statistics.StatusDto"> |
| | | SELECT |
| | | count(1) total, |
| | | sum(case when ubc.state=5 then 1 else 0 end) register, |
| | | sum(case when ubc.state=4 then 1 else 0 end ) notRegister, |
| | | sum(case when ubc.state=9 then 1 else 0 end ) closing, |
| | | sum(case when ubc.state=3 then 1 else 0 end ) relearn, |
| | | sum(case when ubc.state=8 then 1 else 0 end ) checked |
| | | FROM |
| | | `ums_base_case` AS ubc |
| | | JOIN ums_violations AS uv ON ubc.id = uv.id |
| | | LEFT JOIN ums_data_dictionary AS t3 ON uv.category_id = t3.id |
| | | LEFT JOIN ums_data_dictionary AS t4 ON uv.type_id = t4.id |
| | | LEFT JOIN ums_sccg_region t5 ON ubc.street_id = t5.id |
| | | WHERE |
| | | ubc.category =1 |
| | | and t4.`id` = #{dictionaryId} |
| | | and t4.`name` IS NOT NULL |
| | | <if test="startTime !='' and endTime !='' and startTime!=null and endTime !=null"> |
| | | and ubc.create_time between #{startTime} and #{endTime} |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="getDataByTypeExp" resultType="com.ycl.dto.statistics.CategoryDto"> |
| | | <!-- 按照违规类型统计--> |
| | | <select id="getDataByType" resultType="com.ycl.dto.statistics.UnlawfulDto"> |
| | | SELECT |
| | | t4.id id, |
| | | t4.NAME name |
| | | FROM |
| | | `ums_base_case` AS ubc |
| | | JOIN ums_violations AS uv ON ubc.id = uv.id |
| | | LEFT JOIN ums_data_dictionary AS t3 ON uv.category_id = t3.id |
| | | LEFT JOIN ums_data_dictionary AS t4 ON uv.type_id = t4.id |
| | | LEFT JOIN ums_sccg_region t5 ON ubc.street_id = t5.id |
| | | WHERE |
| | | ubc.category =1 |
| | | and t4.`name` is NOT NULL |
| | | group by |
| | | t4.id |
| | | </select> |
| | | |
| | | |
| | | |
| | | |
| | | <!-- 按照区域统计--> |
| | | <select id="getDataByStreet" resultType="com.ycl.dto.statistics.CategoryDto"> |
| | | SELECT |
| | | ubc.community_id id, |
| | | t5.region_name name |
| | | FROM |
| | | `ums_base_case` AS ubc |
| | | JOIN ums_violations AS uv ON ubc.id = uv.id |
| | | LEFT JOIN ums_data_dictionary AS t3 ON uv.category_id = t3.id |
| | | LEFT JOIN ums_data_dictionary AS t4 ON uv.type_id = t4.id |
| | | LEFT JOIN ums_sccg_region t5 ON ubc.street_id = t5.id |
| | | WHERE |
| | | ubc.category = 1 |
| | | AND t4.`name` IS NOT NULL |
| | | <if test="startTime !='' and endTime !='' and startTime!=null and endTime !=null"> |
| | | and ubc.create_time between #{startTime} and #{endTime} |
| | | </if> |
| | | GROUP BY |
| | | ubc.community_id |
| | | limit #{currentPage}, #{pageSize} |
| | | </select> |
| | | <select id="getStatusDataByStreet" resultType="com.ycl.dto.statistics.StatusDto"> |
| | | SELECT |
| | | count( 1 ) total, |
| | | sum( CASE WHEN ubc.state = 5 THEN 1 ELSE 0 END ) register, |
| | | sum( CASE WHEN ubc.state = 4 THEN 1 ELSE 0 END ) notRegister, |
| | | sum( CASE WHEN ubc.state = 9 THEN 1 ELSE 0 END ) closing, |
| | | sum( CASE WHEN ubc.state = 3 THEN 1 ELSE 0 END ) relearn, |
| | | sum( CASE WHEN ubc.state = 8 THEN 1 ELSE 0 END ) checked |
| | | FROM |
| | | `ums_base_case` AS ubc |
| | | JOIN ums_violations AS uv ON ubc.id = uv.id |
| | | LEFT JOIN ums_data_dictionary AS t3 ON uv.category_id = t3.id |
| | | LEFT JOIN ums_data_dictionary AS t4 ON uv.type_id = t4.id |
| | | LEFT JOIN ums_sccg_region t5 ON ubc.street_id = t5.id |
| | | WHERE |
| | | ubc.category = 1 |
| | | AND ubc.`community_id` = #{streetId} |
| | | AND t4.`name` IS NOT NULL |
| | | <if test="startTime !='' and endTime !='' and startTime!=null and endTime !=null"> |
| | | and ubc.create_time between #{startTime} and #{endTime} |
| | | </if> |
| | | </select> |
| | | <select id="getDataByStreetExp" resultType="com.ycl.dto.statistics.CategoryDto"> |
| | | SELECT |
| | | ubc.community_id id, |
| | | t5.region_name NAME |
| | | FROM |
| | | `ums_base_case` AS ubc |
| | | JOIN ums_violations AS uv ON ubc.id = uv.id |
| | | LEFT JOIN ums_data_dictionary AS t3 ON uv.category_id = t3.id |
| | | LEFT JOIN ums_data_dictionary AS t4 ON uv.type_id = t4.id |
| | | LEFT JOIN ums_sccg_region t5 ON ubc.street_id = t5.id |
| | | WHERE |
| | | ubc.category =1 |
| | | and t4.`name` is NOT NULL |
| | | group by |
| | | ubc.community_id |
| | | </select> |
| | | |
| | | |
| | | |
| | | |
| | | <!-- 按点位统计--> |
| | | <select id="getDataBySite" resultType="java.lang.String"> |
| | | SELECT |
| | | ubc.site |
| | | FROM |
| | | `ums_base_case` AS ubc |
| | | JOIN ums_violations AS uv ON ubc.id = uv.id |
| | | LEFT JOIN ums_data_dictionary AS t3 ON uv.category_id = t3.id |
| | | LEFT JOIN ums_data_dictionary AS t4 ON uv.type_id = t4.id |
| | | LEFT JOIN ums_sccg_region t5 ON ubc.street_id = t5.id |
| | | WHERE |
| | | ubc.category = 1 |
| | | AND t4.`name` IS NOT NULL |
| | | <if test="startTime !='' and endTime !='' and startTime!=null and endTime !=null"> |
| | | and ubc.create_time between #{startTime} and #{endTime} |
| | | </if> |
| | | GROUP BY |
| | | ubc.site |
| | | limit #{currentPage}, #{pageSize} |
| | | </select> |
| | | <select id="getStatusDataBySite" resultType="com.ycl.dto.statistics.StatusDto"> |
| | | SELECT |
| | | count( 1 ) total, |
| | | sum( CASE WHEN ubc.state = 5 THEN 1 ELSE 0 END ) register, |
| | | sum( CASE WHEN ubc.state = 4 THEN 1 ELSE 0 END ) notRegister, |
| | | sum( CASE WHEN ubc.state = 9 THEN 1 ELSE 0 END ) closing, |
| | | sum( CASE WHEN ubc.state = 3 THEN 1 ELSE 0 END ) relearn, |
| | | sum( CASE WHEN ubc.state = 8 THEN 1 ELSE 0 END ) checked |
| | | FROM |
| | | `ums_base_case` AS ubc |
| | | JOIN ums_violations AS uv ON ubc.id = uv.id |
| | | LEFT JOIN ums_data_dictionary AS t3 ON uv.category_id = t3.id |
| | | LEFT JOIN ums_data_dictionary AS t4 ON uv.type_id = t4.id |
| | | LEFT JOIN ums_sccg_region t5 ON ubc.street_id = t5.id |
| | | WHERE |
| | | ubc.category = 1 |
| | | AND t4.`name` IS NOT NULL |
| | | AND ubc.site = #{site} |
| | | </select> |
| | | <select id="getDataBySiteExp" resultType="java.lang.String"> |
| | | SELECT |
| | | ubc.site |
| | | FROM |
| | | `ums_base_case` AS ubc |
| | | JOIN ums_violations AS uv ON ubc.id = uv.id |
| | | LEFT JOIN ums_data_dictionary AS t3 ON uv.category_id = t3.id |
| | | LEFT JOIN ums_data_dictionary AS t4 ON uv.type_id = t4.id |
| | | LEFT JOIN ums_sccg_region t5 ON ubc.street_id = t5.id |
| | | WHERE |
| | | ubc.category = 1 |
| | | AND t4.`name` IS NOT NULL |
| | | GROUP BY |
| | | ubc.site |
| | | </select> |
| | | |
| | | |
| | | |
| | | |
| | | <!-- 按照报警时间--> |
| | | <select id="getDataByTime" resultType="com.ycl.dto.statistics.TimeDto"> |
| | | SELECT |
| | | ubc.id id, |
| | | ubc.alarm_time time |
| | | FROM |
| | | `ums_base_case` AS ubc |
| | | JOIN ums_violations AS uv ON ubc.id = uv.id |
| | | LEFT JOIN ums_data_dictionary AS t3 ON uv.category_id = t3.id |
| | | LEFT JOIN ums_data_dictionary AS t4 ON uv.type_id = t4.id |
| | | LEFT JOIN ums_sccg_region t5 ON ubc.street_id = t5.id |
| | | WHERE |
| | | ubc.category = 1 |
| | | AND t4.`name` IS NOT NULL |
| | | <if test="startTime !='' and endTime !='' and startTime!=null and endTime !=null"> |
| | | and ubc.alarm_time between #{startTime} and #{endTime} |
| | | </if> |
| | | GROUP BY |
| | | ubc.alarm_time |
| | | limit #{currentPage}, #{pageSize} |
| | | </select> |
| | | <select id="getStatusDataByTime" resultType="com.ycl.dto.statistics.StatusDto"> |
| | | SELECT |
| | | count( 1 ) total, |
| | | sum( CASE WHEN ubc.state = 5 THEN 1 ELSE 0 END ) register, |
| | | sum( CASE WHEN ubc.state = 4 THEN 1 ELSE 0 END ) notRegister, |
| | | sum( CASE WHEN ubc.state = 9 THEN 1 ELSE 0 END ) closing, |
| | | sum( CASE WHEN ubc.state = 3 THEN 1 ELSE 0 END ) relearn, |
| | | sum( CASE WHEN ubc.state = 8 THEN 1 ELSE 0 END ) checked |
| | | FROM |
| | | `ums_base_case` AS ubc |
| | | JOIN ums_violations AS uv ON ubc.id = uv.id |
| | | LEFT JOIN ums_data_dictionary AS t3 ON uv.category_id = t3.id |
| | | LEFT JOIN ums_data_dictionary AS t4 ON uv.type_id = t4.id |
| | | LEFT JOIN ums_sccg_region t5 ON ubc.street_id = t5.id |
| | | WHERE |
| | | ubc.category = 1 |
| | | AND t4.`name` IS NOT NULL |
| | | AND ubc.id = #{id} |
| | | </select> |
| | | <select id="getDataByTimeExp" resultType="com.ycl.dto.statistics.TimeDto"> |
| | | SELECT |
| | | ubc.id id, |
| | | ubc.alarm_time time, |
| | | FROM |
| | | `ums_base_case` AS ubc |
| | | JOIN ums_violations AS uv ON ubc.id = uv.id |
| | | LEFT JOIN ums_data_dictionary AS t3 ON uv.category_id = t3.id |
| | | LEFT JOIN ums_data_dictionary AS t4 ON uv.type_id = t4.id |
| | | LEFT JOIN ums_sccg_region t5 ON ubc.street_id = t5.id |
| | | WHERE |
| | | ubc.category =1 |
| | | and t4.`name` is NOT NULL |
| | | group by |
| | | ubc.alarm_time |
| | | </select> |
| | | |
| | | |
| | | |
| | | |
| | | <!-- 分页数量--> |
| | | <select id="getTotalByType" resultType="java.lang.Integer"> |
| | | SELECT |
| | | count(*) num |
| | | t4.id id, |
| | | t4.NAME name, |
| | | COUNT(DISTINCT ubc.id) count, |
| | | sum(case when ubc.state >4 then 1 ELSE 0 END ) register, |
| | | sum(case when ubc.state =4 then 1 ELSE 0 END ) notRegister, |
| | | sum(case when ubc.state =9 then 1 ELSE 0 END ) closing, |
| | | sum(case when ubc.state =3 then 1 ELSE 0 END ) relearn, |
| | | sum(case when ubc.state =8 then 1 ELSE 0 END ) checked |
| | | FROM |
| | | `ums_base_case` AS ubc |
| | | JOIN ums_violations AS uv ON ubc.id = uv.id |
| | | LEFT JOIN ums_data_dictionary AS t3 ON uv.category_id = t3.id |
| | | LEFT JOIN ums_data_dictionary AS t4 ON uv.type_id = t4.id |
| | | LEFT JOIN ums_data_dictionary AS t4 ON uv.grade_id = t4.id |
| | | LEFT JOIN ums_sccg_region t5 ON ubc.street_id = t5.id |
| | | WHERE |
| | | ubc.category =1 |
| | |
| | | <if test="startTime !='' and endTime !='' and startTime!=null and endTime !=null"> |
| | | and ubc.create_time between #{startTime} and #{endTime} |
| | | </if> |
| | | group by t4.id |
| | | ORDER BY t4.id |
| | | </select> |
| | | <select id="getTotalByStreet" resultType="java.lang.Integer"> |
| | | |
| | | <!-- 按照区域统计--> |
| | | <select id="getDataByStreet" resultType="com.ycl.dto.statistics.UnlawfulDto"> |
| | | SELECT |
| | | count(*) num |
| | | FROM |
| | | `ums_base_case` AS ubc |
| | | JOIN ums_violations AS uv ON ubc.id = uv.id |
| | | LEFT JOIN ums_data_dictionary AS t3 ON uv.category_id = t3.id |
| | | LEFT JOIN ums_data_dictionary AS t4 ON uv.type_id = t4.id |
| | | LEFT JOIN ums_sccg_region t5 ON ubc.street_id = t5.id |
| | | WHERE |
| | | ubc.category =1 |
| | | and t4.`name` is NOT NULL |
| | | <if test="startTime !='' and endTime !='' and startTime!=null and endTime !=null"> |
| | | and ubc.create_time between #{startTime} and #{endTime} |
| | | </if> |
| | | </select> |
| | | <select id="getTotalBySite" resultType="java.lang.Integer"> |
| | | SELECT |
| | | count(*) num |
| | | ubc.street_id id, |
| | | t5.region_name name, |
| | | COUNT( DISTINCT ubc.id ) count, |
| | | sum( CASE WHEN ubc.state > 4 THEN 1 ELSE 0 END ) register, |
| | | sum( CASE WHEN ubc.state = 4 THEN 1 ELSE 0 END ) notRegister, |
| | | sum( CASE WHEN ubc.state = 9 THEN 1 ELSE 0 END ) closing, |
| | | sum( CASE WHEN ubc.state = 3 THEN 1 ELSE 0 END ) relearn, |
| | | sum( CASE WHEN ubc.state = 8 THEN 1 ELSE 0 END ) checked |
| | | FROM |
| | | `ums_base_case` AS ubc |
| | | JOIN ums_violations AS uv ON ubc.id = uv.id |
| | |
| | | LEFT JOIN ums_sccg_region t5 ON ubc.street_id = t5.id |
| | | WHERE |
| | | ubc.category = 1 |
| | | AND t4.`name` IS NOT NULL |
| | | AND t5.region_name IS NOT NULL |
| | | <if test="startTime !='' and endTime !='' and startTime!=null and endTime !=null"> |
| | | and ubc.create_time between #{startTime} and #{endTime} |
| | | </if> |
| | | GROUP BY ubc.street_id |
| | | ORDER BY ubc.street_id |
| | | </select> |
| | | <select id="getTotalByTime" resultType="java.lang.Integer"> |
| | | |
| | | <!-- 按照报警时间--> |
| | | <select id="getDataByTime" resultType="com.ycl.dto.statistics.UnlawfulDto"> |
| | | SELECT |
| | | count(*) num |
| | | DATE_FORMAT(ubc.alarm_time,'%Y-%m-%d') NAME, |
| | | COUNT( DISTINCT ubc.id ) count, |
| | | sum( CASE WHEN ubc.state > 4 THEN 1 ELSE 0 END ) register, |
| | | sum( CASE WHEN ubc.state = 4 THEN 1 ELSE 0 END ) notRegister, |
| | | sum( CASE WHEN ubc.state = 9 THEN 1 ELSE 0 END ) closing, |
| | | sum( CASE WHEN ubc.state = 3 THEN 1 ELSE 0 END ) relearn, |
| | | sum( CASE WHEN ubc.state = 8 THEN 1 ELSE 0 END ) checked |
| | | FROM |
| | | `ums_base_case` AS ubc |
| | | JOIN ums_violations AS uv ON ubc.id = uv.id |
| | | LEFT JOIN ums_data_dictionary AS t3 ON uv.category_id = t3.id |
| | | LEFT JOIN ums_data_dictionary AS t4 ON uv.type_id = t4.id |
| | | LEFT JOIN ums_sccg_region t5 ON ubc.street_id = t5.id |
| | | WHERE |
| | | ubc.category = 1 |
| | | AND t4.`name` IS NOT NULL |
| | | <if test="startTime !='' and endTime !='' and startTime!=null and endTime !=null"> |
| | | and ubc.alarm_time between #{startTime} and #{endTime} |
| | | </if> |
| | | GROUP BY |
| | | DATE_FORMAT(ubc.alarm_time,'%Y-%m-%d') |
| | | ORDER BY |
| | | DATE_FORMAT(ubc.alarm_time,'%Y-%m-%d') |
| | | </select> |
| | | |
| | | <select id="getDataByPoint" resultType="com.ycl.dto.statistics.UnlawfulDto"> |
| | | SELECT |
| | | vp.id id, |
| | | vp.NAME name, |
| | | COUNT(DISTINCT ubc.id) count, |
| | | sum(case when ubc.state >4 then 1 ELSE 0 END ) register, |
| | | sum(case when ubc.state =4 then 1 ELSE 0 END ) notRegister, |
| | | sum(case when ubc.state =9 then 1 ELSE 0 END ) closing, |
| | | sum(case when ubc.state =3 then 1 ELSE 0 END ) relearn, |
| | | sum(case when ubc.state =8 then 1 ELSE 0 END ) checked |
| | | FROM |
| | | `ums_base_case` AS ubc |
| | | JOIN ums_violations AS uv ON ubc.id = uv.id |
| | | LEFT JOIN ums_video_point vp ON uv.video_point_id = vp.id |
| | | WHERE |
| | | ubc.category =1 |
| | | and vp.`name` is NOT NULL |
| | | <if test="startTime !='' and endTime !='' and startTime!=null and endTime !=null"> |
| | | and ubc.alarm_time between #{startTime} and #{endTime} |
| | | </if> |
| | | group by vp.id |
| | | ORDER BY vp.id |
| | | </select> |
| | | </mapper> |