| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?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.zsjz.ai.module.trans.mapper.TransSensitiveMapper">
- <select id="statFirstTransSensitive" resultType="com.zsjz.ai.common.model.trans.dto.TransSensitiveDTO">
- with filter_trans as (select personName,transDate,
- COALESCE(otherName, '未知对手') as otherName,
- otherCardNo
- from ${query.tableName}
- <where>
- <if test="query.personNames != null and query.personNames.size > 0">
- AND personName IN
- <foreach collection="query.personNames" item="name" open="(" separator="," close=")">
- #{name}
- </foreach>
- </if>
- <if test="query.personName != null and query.personName != ''">
- AND personName = #{query.personName}
- </if>
- <if test="query.startDate != null">
- and transDate >= #{query.startDate}
- </if>
- <if test="query.endDate != null">
- and transDate <= #{query.endDate}
- </if>
- <if test="query.keyword != null">
- and (otherName = #{query.keyword} OR otherCardNo like CONCAT('%',#{query.keyword},'%'))
- </if>
- </where>
- )
- SELECT
- tr.personName,
- tr.otherName,
- tr.otherCardNo,
- COUNT(*) AS transCount
- FROM filter_trans tr
- JOIN special_date sd ON tr.transDate BETWEEN sd.startDate AND sd.endDate
- GROUP BY
- tr.personName,
- tr.otherName,
- tr.otherCardNo
- ORDER BY transCount DESC
- </select>
- <select id="statSecondTransSensitive" resultType="com.zsjz.ai.common.model.trans.entity.TransRecord">
- with filter_trans as (
- select *
- from ${query.tableName}
- <where>
- <if test="query.personNames != null and query.personNames.size > 0">
- AND personName IN
- <foreach collection="query.personNames" item="name" open="(" separator="," close=")">
- #{name}
- </foreach>
- </if>
- <if test="query.personName != null and query.personName != ''">
- AND personName = #{query.personName}
- </if>
- <if test="query.startDate != null">
- and transDate >= #{query.startDate}
- </if>
- <if test="query.endDate != null">
- and transDate <= #{query.endDate}
- </if>
- <if test="query.otherName != null and query.otherName != ''">
- <choose>
- <when test="query.otherName == '未知对手'">
- and otherName IS NULL
- </when>
- <otherwise>
- and otherName = #{query.otherName}
- </otherwise>
- </choose>
- </if>
- <if test="query.otherCardNo != null and query.otherCardNo != ''">
- <choose>
- <when test="query.otherCardNo == '未知卡号'">
- and otherCardNo IS NULL
- </when>
- <otherwise>
- and otherCardNo = #{query.otherCardNo}
- </otherwise>
- </choose>
- </if>
- </where>
- )
- SELECT
- tr.*,
- sd.name AS festivalName
- FROM filter_trans tr
- JOIN special_date sd ON tr.transDate BETWEEN sd.startDate AND sd.endDate
- order by tr.transDateTime desc
- </select>
- </mapper>
|