| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 |
- <?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.sundot.airport.ledger.mapper.LedgerSeizureStatsMapper">
- <resultMap id="BaseResultMap" type="com.sundot.airport.ledger.domain.LedgerSeizureStats">
- <id property="id" column="id" />
- <result property="recordDate" column="record_date" />
- <result property="deptName" column="dept_name" />
- <result property="deptId" column="dept_id" />
- <result property="teamName" column="team_name" />
- <result property="teamId" column="team_id" />
- <result property="groupName" column="group_name" />
- <result property="groupId" column="group_id" />
- <result property="workArea" column="work_area" />
- <result property="areaId" column="area_id" />
- <result property="qualificationLevel" column="qualification_level" />
- <result property="position" column="position" />
- <result property="positionId" column="position_id" />
- <result property="inspectorName" column="inspector_name" />
- <result property="inspectorId" column="inspector_id" />
- <result property="passengerName" column="passenger_name" />
- <result property="passengerGender" column="passenger_gender" />
- <result property="passengerEthnicity" column="passenger_ethnicity" />
- <result property="passengerAge" column="passenger_age" />
- <result property="flightNo" column="flight_no" />
- <result property="destination" column="destination" />
- <result property="inOutPort" column="in_out_port" />
- <result property="violationSubject" column="violation_subject" />
- <result property="itemCategory" column="item_category" />
- <result property="secondaryCategory" column="secondary_category" />
- <result property="itemName" column="item_name" />
- <result property="itemQuantity" column="item_quantity" />
- <result property="concealmentPart" column="concealment_part" />
- <result property="eventBrief" column="event_brief" />
- <result property="handlingMethod" column="handling_method" />
- <result property="addScore" column="add_score" />
- <result property="scoreDimension" column="score_dimension" />
- <result property="scoreIndicator" column="score_indicator" />
- <result property="evidenceFile" column="evidence_file" />
- <result property="remark" column="remark" />
- <result property="importBatch" column="import_batch" />
- <result property="sourceType" column="source_type" />
- <result property="createBy" column="create_by" />
- <result property="createTime" column="create_time" />
- <result property="updateBy" column="update_by" />
- <result property="updateTime" column="update_time" />
- <result property="syncFlag" column="sync_flag" />
- </resultMap>
- <sql id="selectVo">
- SELECT id, record_date, dept_name, dept_id, team_name, team_id, group_name, group_id,
- work_area, area_id, qualification_level, position, position_id,
- inspector_name, inspector_id,
- passenger_name, passenger_gender, passenger_ethnicity, passenger_age,
- flight_no, destination, in_out_port, violation_subject,
- item_category, secondary_category, item_name, item_quantity,
- concealment_part, event_brief, handling_method,
- add_score, score_dimension, score_indicator, evidence_file, remark,
- import_batch, source_type, create_by, create_time, update_by, update_time, sync_flag
- FROM ledger_seizure_stats
- WHERE del_flag = '0'
- </sql>
- <select id="selectList" parameterType="com.sundot.airport.ledger.domain.LedgerSeizureStats" resultMap="BaseResultMap">
- <include refid="selectVo"/>
- <if test="deptName != null and deptName != ''">AND dept_name LIKE CONCAT('%', #{deptName}, '%')</if>
- <if test="teamName != null and teamName != ''">AND team_name LIKE CONCAT('%', #{teamName}, '%')</if>
- <if test="syncFlag != null and syncFlag != ''">AND sync_flag = #{syncFlag}</if>
- <if test="params != null and params.beginTime != null and params.beginTime != ''">
- AND record_date >= #{params.beginTime}
- </if>
- <if test="params != null and params.endTime != null and params.endTime != ''">
- AND record_date <= #{params.endTime}
- </if>
- ORDER BY id DESC
- </select>
- <update id="updateSyncFlag">
- update ledger_seizure_stats
- set sync_flag = '1'
- where sync_flag = '0'
- </update>
- <select id="countByInspectorAndDateRange" resultType="int">
- SELECT count(*)
- FROM ledger_seizure_stats
- WHERE del_flag = '0'
- AND inspector_name = #{inspectorName}
- <if test="beginTime != null and beginTime != ''">
- AND record_date >= STR_TO_DATE(#{beginTime}, '%Y-%m-%d')
- </if>
- <if test="endTime != null and endTime != ''">
- AND record_date <= STR_TO_DATE(#{endTime}, '%Y-%m-%d')
- </if>
- </select>
- <select id="countSeizureTotalQuantity" parameterType="com.sundot.airport.ledger.domain.vo.CountQueryReqVO" resultType="com.sundot.airport.ledger.domain.vo.CountSeizureTotalQuantityResVO">
- SELECT
- record_date AS recordDate,
- <!-- 动态分组名称 -->
- <choose>
- <when test="groupId != null">group_name AS groupName</when>
- <when test="teamId != null">team_name AS groupName</when>
- <when test="deptId != null">dept_name AS groupName</when>
- <otherwise>'站' AS groupName</otherwise>
- </choose>,
- IFNULL(SUM(item_quantity), 0) AS seizeQuantity
- FROM ledger_seizure_stats
- <where>
- <include refid="FILTER_FIXED_DATE_CRITERIA_SQL"/>
- </where>
- <!-- 动态分组:重点!全为空时仅按日期分组 -->
- GROUP BY
- <choose>
- <when test="groupId != null">group_id, record_date, group_name</when>
- <when test="teamId != null">team_id, record_date, team_name</when>
- <when test="deptId != null">dept_id, record_date, dept_name</when>
- <otherwise>record_date</otherwise>
- </choose>
- ORDER BY record_date ASC
- </select>
- <select id="countSeizureSingleQuantity" parameterType="com.sundot.airport.ledger.domain.vo.CountQueryReqVO" resultType="com.sundot.airport.ledger.domain.vo.CountSeizureSingleQuantityResVO">
- SELECT
- record_date AS recordDate,
- <!-- 动态显示维度名称:员工/小组/班组/部门 -->
- <choose>
- <when test="groupId != null">inspector_name AS groupName</when>
- <when test="teamId != null">group_name AS groupName</when>
- <when test="deptId != null">team_name AS groupName</when>
- <otherwise>dept_name AS groupName</otherwise>
- </choose>,
- IFNULL(SUM(item_quantity), 0) AS seizeQuantity
- FROM ledger_seizure_stats
- <where>
- <include refid="FILTER_FIXED_DATE_CRITERIA_SQL"/>
- </where>
- <!-- 动态分组,严格层级下钻 -->
- GROUP BY
- <choose>
- <when test="groupId != null">inspector_id, record_date, inspector_name</when>
- <when test="teamId != null">group_id, record_date, group_name</when>
- <when test="deptId != null">team_id, record_date, team_name</when>
- <otherwise>dept_id, record_date, dept_name</otherwise>
- </choose>
- ORDER BY record_date ASC
- </select>
- <!-- 明细查询:动态下钻维度 -->
- <select id="statsTimeRangeItem" parameterType="com.sundot.airport.ledger.domain.vo.CountQueryReqVO" resultType="com.sundot.airport.ledger.domain.vo.SeizeItemVO">
- SELECT
- <choose>
- <when test="groupId != null">inspector_name AS name</when>
- <when test="teamId != null">group_name AS name</when>
- <when test="deptId != null">team_name AS name</when>
- <otherwise>dept_name AS name</otherwise>
- </choose>,
- IFNULL(SUM(item_quantity), 0) AS seizeNum
- FROM ledger_seizure_stats
- <where>
- <include refid="FILTER_FIXED_CRITERIA_SQL"/>
- </where>
- GROUP BY
- <choose>
- <when test="groupId != null">inspector_id, inspector_name</when>
- <when test="teamId != null">group_id, group_name</when>
- <when test="deptId != null">team_id, team_name</when>
- <otherwise>dept_id, dept_name</otherwise>
- </choose>
- ORDER BY seizeNum DESC
- </select>
- <!-- 总查获数查询 -->
- <select id="statsTimeRangeTotal" parameterType="com.sundot.airport.ledger.domain.vo.CountQueryReqVO" resultType="java.lang.Integer">
- SELECT IFNULL(SUM(item_quantity), 0)
- FROM ledger_seizure_stats
- <where>
- <include refid="FILTER_FIXED_CRITERIA_SQL"/>
- </where>
- </select>
- <select id="countSeizeSubjectItemQuantity" parameterType="com.sundot.airport.ledger.domain.vo.CountQueryReqVO" resultType="com.sundot.airport.ledger.domain.vo.SeizeCategoryQuantityVO">
- SELECT item_name AS itemName, IFNULL(SUM(item_quantity), 0) AS itemNum
- FROM ledger_seizure_stats
- <where>
- <include refid="FILTER_FIXED_CRITERIA_SQL"/>
- <!-- 过滤空类别,避免脏数据 -->
- AND item_name IS NOT NULL
- AND item_name != ''
- </where>
- GROUP BY item_name
- ORDER BY itemNum DESC
- </select>
- <select id="countSeizeAreaQuantity" parameterType="com.sundot.airport.ledger.domain.vo.CountQueryReqVO" resultType="com.sundot.airport.ledger.domain.vo.SeizureAreaVO">
- SELECT area_id AS areaId, work_area AS workArea, IFNULL(SUM(item_quantity), 0) AS areaSeizeNum
- FROM ledger_seizure_stats
- <where>
- <include refid="FILTER_FIXED_CRITERIA_SQL"/>
- <!-- 过滤空区域脏数据 -->
- AND work_area IS NOT NULL AND work_area != ''
- </where>
- GROUP BY area_id, work_area
- ORDER BY areaSeizeNum DESC
- </select>
- <sql id="FILTER_FIXED_CRITERIA_SQL">
- del_flag = '0'
- <if test="startDate != null and endDate != null">
- AND record_date BETWEEN #{startDate,jdbcType=TIMESTAMP} AND #{endDate,jdbcType=TIMESTAMP}
- </if>
- <include refid="FILTER_CRITERIA_SQL"/>
- </sql>
- <sql id="FILTER_FIXED_DATE_CRITERIA_SQL">
- del_flag = '0'
- <!-- 近30天自然日 -->
- AND record_date >= DATE_SUB(CURDATE(), INTERVAL 29 DAY)
- AND record_date <= CURDATE()
- <include refid="FILTER_CRITERIA_SQL"/>
- </sql>
- <sql id="FILTER_CRITERIA_SQL">
- <!-- 三级联动筛选 -->
- <if test="deptId != null">AND dept_id = #{deptId}</if>
- <if test="teamId != null">AND team_id = #{teamId}</if>
- <if test="groupId != null">AND group_id = #{groupId}</if>
- <!-- 筛选空值 -->
- AND dept_id IS NOT NULL AND dept_id != ''
- AND team_id IS NOT NULL AND team_id != ''
- AND inspector_id IS NOT NULL AND inspector_id != ''
- </sql>
- </mapper>
|