TransSensitiveMapper.xml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.zsjz.ai.module.trans.mapper.TransSensitiveMapper">
  4. <select id="statFirstTransSensitive" resultType="com.zsjz.ai.common.model.trans.dto.TransSensitiveDTO">
  5. with filter_trans as (select personName,transDate,
  6. COALESCE(otherName, '未知对手') as otherName,
  7. otherCardNo
  8. from ${query.tableName}
  9. <where>
  10. <if test="query.personNames != null and query.personNames.size > 0">
  11. AND personName IN
  12. <foreach collection="query.personNames" item="name" open="(" separator="," close=")">
  13. #{name}
  14. </foreach>
  15. </if>
  16. <if test="query.personName != null and query.personName != ''">
  17. AND personName = #{query.personName}
  18. </if>
  19. <if test="query.startDate != null">
  20. and transDate >= #{query.startDate}
  21. </if>
  22. <if test="query.endDate != null">
  23. and transDate &lt;= #{query.endDate}
  24. </if>
  25. <if test="query.keyword != null">
  26. and (otherName = #{query.keyword} OR otherCardNo like CONCAT('%',#{query.keyword},'%'))
  27. </if>
  28. </where>
  29. )
  30. SELECT
  31. tr.personName,
  32. tr.otherName,
  33. tr.otherCardNo,
  34. COUNT(*) AS transCount
  35. FROM filter_trans tr
  36. JOIN special_date sd ON tr.transDate BETWEEN sd.startDate AND sd.endDate
  37. GROUP BY
  38. tr.personName,
  39. tr.otherName,
  40. tr.otherCardNo
  41. ORDER BY transCount DESC
  42. </select>
  43. <select id="statSecondTransSensitive" resultType="com.zsjz.ai.common.model.trans.entity.TransRecord">
  44. with filter_trans as (
  45. select *
  46. from ${query.tableName}
  47. <where>
  48. <if test="query.personNames != null and query.personNames.size > 0">
  49. AND personName IN
  50. <foreach collection="query.personNames" item="name" open="(" separator="," close=")">
  51. #{name}
  52. </foreach>
  53. </if>
  54. <if test="query.personName != null and query.personName != ''">
  55. AND personName = #{query.personName}
  56. </if>
  57. <if test="query.startDate != null">
  58. and transDate >= #{query.startDate}
  59. </if>
  60. <if test="query.endDate != null">
  61. and transDate &lt;= #{query.endDate}
  62. </if>
  63. <if test="query.otherName != null and query.otherName != ''">
  64. <choose>
  65. <when test="query.otherName == '未知对手'">
  66. and otherName IS NULL
  67. </when>
  68. <otherwise>
  69. and otherName = #{query.otherName}
  70. </otherwise>
  71. </choose>
  72. </if>
  73. <if test="query.otherCardNo != null and query.otherCardNo != ''">
  74. <choose>
  75. <when test="query.otherCardNo == '未知卡号'">
  76. and otherCardNo IS NULL
  77. </when>
  78. <otherwise>
  79. and otherCardNo = #{query.otherCardNo}
  80. </otherwise>
  81. </choose>
  82. </if>
  83. </where>
  84. )
  85. SELECT
  86. tr.*,
  87. sd.name AS festivalName
  88. FROM filter_trans tr
  89. JOIN special_date sd ON tr.transDate BETWEEN sd.startDate AND sd.endDate
  90. order by tr.transDateTime desc
  91. </select>
  92. </mapper>