RepalRemindHistoryMapper.xml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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.winhc.repal.repository.RepalRemindHistoryMapper">
  4. <select id="getRemindUnReadVO" resultType="com.winhc.repal.model.vo.RepalBillRemindUnReadVO">
  5. SELECT
  6. ( SELECT count(*) FROM REPAL_REMIND_HISTORY WHERE REPAL_BOOK_ID = #{repalBookId} AND REPAL_BILL_ID = #{repalBillId}
  7. <if test="startTime != null">
  8. AND REMIND_TIME >= #{startTime}
  9. </if>
  10. <if test="endTime != null">
  11. AND REMIND_TIME <![CDATA[<=]]> #{endTime}
  12. </if>
  13. AND REMIND_TYPE = 'RISK' AND ID > #{riskId} ) AS unreadRiskCount,
  14. ( SELECT count(*) FROM REPAL_REMIND_HISTORY WHERE REPAL_BOOK_ID = #{repalBookId} AND REPAL_BILL_ID = #{repalBillId}
  15. <if test="startTime != null">
  16. AND REMIND_TIME >= #{startTime}
  17. </if>
  18. <if test="endTime != null">
  19. AND REMIND_TIME <![CDATA[<=]]> #{endTime}
  20. </if>
  21. AND REMIND_TYPE = 'RANK' AND ID > #{rankId} ) AS unreadRankCount,
  22. ( SELECT count(*) FROM REPAL_REMIND_HISTORY WHERE REPAL_BOOK_ID = #{repalBookId} AND REPAL_BILL_ID = #{repalBillId}
  23. <if test="startTime != null">
  24. AND REMIND_TIME >= #{startTime}
  25. </if>
  26. <if test="endTime != null">
  27. AND REMIND_TIME <![CDATA[<=]]> #{endTime}
  28. </if>
  29. AND REMIND_TYPE = 'OVERDUE' AND ID > #{overdueId} ) AS unreadOverdueCount,
  30. ( SELECT count(*) FROM REPAL_REMIND_HISTORY WHERE REPAL_BOOK_ID = #{repalBookId} AND REPAL_BILL_ID = #{repalBillId}
  31. <if test="startTime != null">
  32. AND REMIND_TIME >= #{startTime}
  33. </if>
  34. <if test="endTime != null">
  35. AND REMIND_TIME <![CDATA[<=]]> #{endTime}
  36. </if>
  37. AND REMIND_TYPE = 'FINANCE' AND ID > #{financeId} ) AS unreadFinanceCount
  38. FROM
  39. DUAL
  40. </select>
  41. <select id="remindCount" resultType="com.winhc.repal.model.vo.RepalRemindCountVO">
  42. select (select count(*) from REPAL_REMIND_HISTORY where REMIND_TYPE = 'OVERDUE'
  43. and REMIND_TIME >= #{localDateTime}
  44. and REPAL_BILL_ID = #{repalBillId}
  45. ) AS overdueCount,
  46. (select count(*) from REPAL_REMIND_HISTORY where REMIND_TYPE = 'OVERDUE'
  47. AND REMIND_TIME >= #{localDateTime}
  48. and REPAL_BILL_ID = #{repalBillId}
  49. AND ID > #{overdueId} ) AS unreadOverdueCount,
  50. (select count(*) from REPAL_REMIND_HISTORY where REMIND_TYPE = 'RISK'
  51. AND REMIND_TIME >= #{localDateTime}
  52. and REPAL_BILL_ID = #{repalBillId}) AS riskCount,
  53. (select count(*) from REPAL_REMIND_HISTORY where REMIND_TYPE = 'RISK'
  54. AND REMIND_TIME >= #{localDateTime}
  55. and REPAL_BILL_ID = #{repalBillId}
  56. AND ID > #{riskId}) AS unreadRiskCount,
  57. (select count(*) from REPAL_REMIND_HISTORY where REMIND_TYPE = 'FINANCE'
  58. and REPAL_BILL_ID = #{repalBillId}
  59. AND REMIND_TIME >= #{localDateTime}) AS financeCount,
  60. (select count(*) from REPAL_REMIND_HISTORY where REMIND_TYPE = 'FINANCE'
  61. AND REMIND_TIME >= #{localDateTime}
  62. and REPAL_BILL_ID = #{repalBillId}
  63. AND ID > #{financeId} ) AS unreadFinanceCount,
  64. (select count(*) from REPAL_REMIND_HISTORY where REMIND_TYPE = 'RANK'
  65. and REPAL_BILL_ID = #{repalBillId}
  66. AND REMIND_TIME >= #{localDateTime}) AS rankCount,
  67. (select count(*) from REPAL_REMIND_HISTORY where REMIND_TYPE = 'RANK'
  68. AND REMIND_TIME >= #{localDateTime}
  69. and REPAL_BILL_ID = #{repalBillId}
  70. AND ID > #{rankId}) AS unreadRankCount,
  71. (select count(*) from REPAL_REMIND_HISTORY where REPAL_BILL_ID = #{repalBillId}
  72. AND REMIND_TIME >= #{localDateTime}) AS totalCount,
  73. (select count(*) from REPAL_REMIND_HISTORY where REMIND_TYPE = 'OVERDUE'
  74. AND REMIND_TIME >= #{localDateTime}
  75. and REPAL_BILL_ID = #{repalBillId}
  76. AND ID > #{overdueId} )+
  77. (select count(*) from REPAL_REMIND_HISTORY where REMIND_TYPE = 'RISK'
  78. AND REMIND_TIME >= #{localDateTime}
  79. and REPAL_BILL_ID = #{repalBillId}
  80. AND ID > #{riskId})+
  81. (select count(*) from REPAL_REMIND_HISTORY where REMIND_TYPE = 'FINANCE'
  82. AND REMIND_TIME >= #{localDateTime}
  83. and REPAL_BILL_ID = #{repalBillId}
  84. AND ID > #{financeId} )+
  85. (select count(*) from REPAL_REMIND_HISTORY where REMIND_TYPE = 'RANK'
  86. AND REMIND_TIME >= #{localDateTime}
  87. and REPAL_BILL_ID = #{repalBillId}
  88. AND ID > #{rankId}) as unreadTotalCount
  89. FROM DUAL
  90. </select>
  91. <select id="getBookDynamicCount" resultType="com.winhc.repal.model.bo.BookDynamicCountBO">
  92. SELECT count(*) AS totalCount, tt.REMIND_TYPE AS remindType FROM REPAL_REMIND_HISTORY AS tt
  93. <if test="userId != null">
  94. LEFT JOIN REPAL_RESPONSIBLE_PERSON AS rPerson ON rPerson.REPAL_BOOK_ID = #{repalBookId}
  95. </if>
  96. LEFT JOIN REPAL_BILL AS bill ON bill.ID = tt.REPAL_BILL_ID
  97. WHERE
  98. tt.REPAL_BOOK_ID = #{repalBookId} AND bill.DELETED = 0
  99. <if test="startDateTime != null">
  100. AND tt.REMIND_TIME >= #{startDateTime}
  101. </if>
  102. <if test="endDateTime != null">
  103. AND tt.REMIND_TIME <![CDATA[<=]]> #{endDateTime}
  104. </if>
  105. <if test="userId != null">
  106. AND rPerson.USER_ID = #{userId}
  107. </if>
  108. GROUP BY tt.REMIND_TYPE
  109. </select>
  110. </mapper>