|
@@ -0,0 +1,142 @@
|
|
|
+<?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.sooka.sponest.lawenforcement.record.mapper.LawenforcementViewMapper">
|
|
|
+
|
|
|
+ <select id="getRecordReport" parameterType="LawenforcementViewBO" resultType="map">
|
|
|
+ SELECT
|
|
|
+ <if test="mark != null and mark == 'dept'">
|
|
|
+ a.dept_name deptName,
|
|
|
+ count(record_status IN ('lawenforcement_type_3', 'lawenforcement_type_4', 'lawenforcement_type_6') OR NULL)
|
|
|
+ ing,
|
|
|
+ IFNULL(yujing, 0) yujing,
|
|
|
+ count(record_status IN ('lawenforcement_type_3', 'lawenforcement_type_4', 'lawenforcement_type_5') OR NULL)
|
|
|
+ two,
|
|
|
+ </if>
|
|
|
+ <if test="mark != null and mark == 'person'">
|
|
|
+ p.dept_name deptName,
|
|
|
+ p.person_name personName,
|
|
|
+ count(record_status IN ('lawenforcement_type_3', 'lawenforcement_type_4', 'lawenforcement_type_5') OR NULL)
|
|
|
+ two,
|
|
|
+ </if>
|
|
|
+ <if test="mark != null and mark == 'obj'">
|
|
|
+ check_object_name objName,
|
|
|
+ check_object_code objCode,
|
|
|
+ check_object_phone objPhone,
|
|
|
+ dict_label objType,
|
|
|
+ IFNULL(SUM(subitem_count), 0) sub,
|
|
|
+ concat(ROUND(IFNULL(count(evaluation = 1 OR NULL) / count(*), 0) * 100, 2), '%') haoping,
|
|
|
+ </if>
|
|
|
+ <if test="mark != null and mark == 'item'">
|
|
|
+ dict_label dictLabel,
|
|
|
+ count(DISTINCT a.dept_name) dept,
|
|
|
+ count(DISTINCT check_object_name) obj,
|
|
|
+ IFNULL(SUM(subitem_count), 0) sub,
|
|
|
+ </if>
|
|
|
+ count(*) total,
|
|
|
+ count(c.record_id) lian,
|
|
|
+ concat(ROUND(IFNULL(c.record_id / count(*), 0) * 100, 2), '%') caseload
|
|
|
+ FROM lawenforcement_record a
|
|
|
+ <if test="mark != null and mark == 'dept'">
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT dept_name, count(*) yujing FROM ${onest_event}.centerevent_t_eventcatalogue WHERE event_type_xl =
|
|
|
+ 1301
|
|
|
+ <if test="startDate != null and startDate != ''">
|
|
|
+ AND create_time >= #{startDate}
|
|
|
+ </if>
|
|
|
+ <if test="endDate != null and endDate != ''">
|
|
|
+ AND create_time <= #{endDate}
|
|
|
+ </if>
|
|
|
+ GROUP BY dept_name) e ON e.dept_name = a.dept_name
|
|
|
+ </if>
|
|
|
+ <if test="mark != null and mark == 'person'">
|
|
|
+ LEFT JOIN lawenforcement_person p ON p.record_id = a.id AND main_person = 1
|
|
|
+ </if>
|
|
|
+ <if test="mark != null and mark == 'obj'">
|
|
|
+ LEFT JOIN ${onest_system}.sys_dict_data dict ON dict.dict_value = a.job_type AND dict_type =
|
|
|
+ 'lawenforcement_objType'
|
|
|
+ </if>
|
|
|
+ LEFT JOIN lawenforcement_case c ON c.record_id = a.id
|
|
|
+ <if test="mark != null and mark == 'item'">
|
|
|
+ RIGHT JOIN ${onest_system}.sys_dict_data dict ON dict.dict_value = a.job_type
|
|
|
+ </if>
|
|
|
+ <where>
|
|
|
+ <if test="mark != null and mark == 'item'">
|
|
|
+ AND dict_type = 'lawenforcement_jobType'
|
|
|
+ </if>
|
|
|
+ <if test="deptName != null and deptName != ''">
|
|
|
+ AND a.dept_name LIKE CONCAT('%', #{deptName}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="personName != null and personName != ''">
|
|
|
+ AND p.person_name LIKE CONCAT('%', #{personName}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="objName != null and objName != ''">
|
|
|
+ AND check_object_name LIKE CONCAT('%', #{objName}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="objCode != null and objCode != ''">
|
|
|
+ AND check_object_code LIKE CONCAT('%', #{objCode}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="objPhone != null and objPhone != ''">
|
|
|
+ AND check_object_phone LIKE CONCAT('%', #{objPhone}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="objType != null and objType != ''">
|
|
|
+ AND check_object_type = #{objType}
|
|
|
+ </if>
|
|
|
+ <if test="jobType != null and jobType != ''">
|
|
|
+ AND job_type = #{jobType}
|
|
|
+ </if>
|
|
|
+ <if test="startDate != null and startDate != ''">
|
|
|
+ AND check_start_time >= #{startDate}
|
|
|
+ </if>
|
|
|
+ <if test="endDate != null and endDate != ''">
|
|
|
+ AND check_end_time <= #{endDate}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY
|
|
|
+ <if test="mark != null and mark == 'dept'">
|
|
|
+ deptName
|
|
|
+ </if>
|
|
|
+ <if test="mark != null and mark == 'person'">
|
|
|
+ deptName,personName
|
|
|
+ </if>
|
|
|
+ <if test="mark != null and mark == 'obj'">
|
|
|
+ objName,objCode,objPhone,objType
|
|
|
+ </if>
|
|
|
+ <if test="mark != null and mark == 'item'">
|
|
|
+ dictLabel
|
|
|
+ </if>
|
|
|
+ WITH ROLLUP
|
|
|
+ <if test="mark != null and mark == 'person'">
|
|
|
+ HAVING deptName IS NULL OR personName IS NOT NULL
|
|
|
+ </if>
|
|
|
+ <if test="mark != null and mark == 'obj'">
|
|
|
+ HAVING objName IS NULL OR objType IS NOT NULL
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="getRecordYearMonth" parameterType="LawenforcementViewBO" resultType="map">
|
|
|
+ SELECT a.d, IFNULL(r.total, 0) total, IFNULL(c.lian, 0) lian, IFNULL(e.yujing, 0) yujing FROM (
|
|
|
+ <foreach item="date" collection="dates" open="select" separator="union" close="">
|
|
|
+ #{date} d
|
|
|
+ </foreach>) a
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT DATE_FORMAT( FROM_UNIXTIME( SUBSTR( check_start_time, 1, 10 ) ),
|
|
|
+ <if test="mark != null and mark == 'dept'">'%Y-%m'</if>
|
|
|
+ <if test="mark != null and mark == 'person'">'%Y-%m-%d'</if>) d, count(*) total,
|
|
|
+ count(DISTINCT check_object_name) obj
|
|
|
+ FROM lawenforcement_record GROUP BY d) r ON r.d = a.d
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT DATE_FORMAT( create_time,
|
|
|
+ <if test="mark != null and mark == 'dept'">'%Y-%m'</if>
|
|
|
+ <if test="mark != null and mark == 'person">'%Y-%m-%d'</if>) d, count(*) lian
|
|
|
+ FROM lawenforcement_case GROUP BY d) c ON c.d = a.d
|
|
|
+ <if test="mark != null and mark == 'dept'">
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT DATE_FORMAT( create_time,
|
|
|
+ <if test="mark != null and mark == 'dept'">'%Y-%m'</if>
|
|
|
+ <if test="mark != null and mark == 'person'">'%Y-%m-%d'</if>) d, count(*) yujing
|
|
|
+ FROM ${onest_event}.centerevent_t_eventcatalogue WHERE event_type_xl = 1301 GROUP BY d) e ON e.d = a.d
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
+</mapper>
|