123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- <?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.winhc.repal.repository.RepalRemindHistoryMapper">
- <select id="getRemindUnReadVO" resultType="com.winhc.repal.model.vo.RepalBillRemindUnReadVO">
- SELECT
- ( SELECT count(*) FROM REPAL_REMIND_HISTORY WHERE REPAL_BOOK_ID = #{repalBookId} AND REPAL_BILL_ID = #{repalBillId}
- <if test="startTime != null">
- AND REMIND_TIME >= #{startTime}
- </if>
- <if test="endTime != null">
- AND REMIND_TIME <![CDATA[<=]]> #{endTime}
- </if>
- AND REMIND_TYPE = 'RISK' AND ID > #{riskId} ) AS unreadRiskCount,
- ( SELECT count(*) FROM REPAL_REMIND_HISTORY WHERE REPAL_BOOK_ID = #{repalBookId} AND REPAL_BILL_ID = #{repalBillId}
- <if test="startTime != null">
- AND REMIND_TIME >= #{startTime}
- </if>
- <if test="endTime != null">
- AND REMIND_TIME <![CDATA[<=]]> #{endTime}
- </if>
- AND REMIND_TYPE = 'RANK' AND ID > #{rankId} ) AS unreadRankCount,
- ( SELECT count(*) FROM REPAL_REMIND_HISTORY WHERE REPAL_BOOK_ID = #{repalBookId} AND REPAL_BILL_ID = #{repalBillId}
- <if test="startTime != null">
- AND REMIND_TIME >= #{startTime}
- </if>
- <if test="endTime != null">
- AND REMIND_TIME <![CDATA[<=]]> #{endTime}
- </if>
- AND REMIND_TYPE = 'OVERDUE' AND ID > #{overdueId} ) AS unreadOverdueCount,
- ( SELECT count(*) FROM REPAL_REMIND_HISTORY WHERE REPAL_BOOK_ID = #{repalBookId} AND REPAL_BILL_ID = #{repalBillId}
- <if test="startTime != null">
- AND REMIND_TIME >= #{startTime}
- </if>
- <if test="endTime != null">
- AND REMIND_TIME <![CDATA[<=]]> #{endTime}
- </if>
- AND REMIND_TYPE = 'FINANCE' AND ID > #{financeId} ) AS unreadFinanceCount
- FROM
- DUAL
- </select>
- <select id="remindCount" resultType="com.winhc.repal.model.vo.RepalRemindCountVO">
- select (select count(*) from REPAL_REMIND_HISTORY where REMIND_TYPE = 'OVERDUE'
- and REMIND_TIME >= #{localDateTime}
- and REPAL_BILL_ID = #{repalBillId}
- ) AS overdueCount,
- (select count(*) from REPAL_REMIND_HISTORY where REMIND_TYPE = 'OVERDUE'
- AND REMIND_TIME >= #{localDateTime}
- and REPAL_BILL_ID = #{repalBillId}
- AND ID > #{overdueId} ) AS unreadOverdueCount,
- (select count(*) from REPAL_REMIND_HISTORY where REMIND_TYPE = 'RISK'
- AND REMIND_TIME >= #{localDateTime}
- and REPAL_BILL_ID = #{repalBillId}) AS riskCount,
- (select count(*) from REPAL_REMIND_HISTORY where REMIND_TYPE = 'RISK'
- AND REMIND_TIME >= #{localDateTime}
- and REPAL_BILL_ID = #{repalBillId}
- AND ID > #{riskId}) AS unreadRiskCount,
- (select count(*) from REPAL_REMIND_HISTORY where REMIND_TYPE = 'FINANCE'
- and REPAL_BILL_ID = #{repalBillId}
- AND REMIND_TIME >= #{localDateTime}) AS financeCount,
- (select count(*) from REPAL_REMIND_HISTORY where REMIND_TYPE = 'FINANCE'
- AND REMIND_TIME >= #{localDateTime}
- and REPAL_BILL_ID = #{repalBillId}
- AND ID > #{financeId} ) AS unreadFinanceCount,
- (select count(*) from REPAL_REMIND_HISTORY where REMIND_TYPE = 'RANK'
- and REPAL_BILL_ID = #{repalBillId}
- AND REMIND_TIME >= #{localDateTime}) AS rankCount,
- (select count(*) from REPAL_REMIND_HISTORY where REMIND_TYPE = 'RANK'
- AND REMIND_TIME >= #{localDateTime}
- and REPAL_BILL_ID = #{repalBillId}
- AND ID > #{rankId}) AS unreadRankCount,
- (select count(*) from REPAL_REMIND_HISTORY where REPAL_BILL_ID = #{repalBillId}
- AND REMIND_TIME >= #{localDateTime}) AS totalCount,
- (select count(*) from REPAL_REMIND_HISTORY where REMIND_TYPE = 'OVERDUE'
- AND REMIND_TIME >= #{localDateTime}
- and REPAL_BILL_ID = #{repalBillId}
- AND ID > #{overdueId} )+
- (select count(*) from REPAL_REMIND_HISTORY where REMIND_TYPE = 'RISK'
- AND REMIND_TIME >= #{localDateTime}
- and REPAL_BILL_ID = #{repalBillId}
- AND ID > #{riskId})+
- (select count(*) from REPAL_REMIND_HISTORY where REMIND_TYPE = 'FINANCE'
- AND REMIND_TIME >= #{localDateTime}
- and REPAL_BILL_ID = #{repalBillId}
- AND ID > #{financeId} )+
- (select count(*) from REPAL_REMIND_HISTORY where REMIND_TYPE = 'RANK'
- AND REMIND_TIME >= #{localDateTime}
- and REPAL_BILL_ID = #{repalBillId}
- AND ID > #{rankId}) as unreadTotalCount
- FROM DUAL
- </select>
- <select id="getBookDynamicCount" resultType="com.winhc.repal.model.bo.BookDynamicCountBO">
- SELECT count(*) AS totalCount, tt.REMIND_TYPE AS remindType FROM REPAL_REMIND_HISTORY AS tt
- <if test="userId != null">
- LEFT JOIN REPAL_RESPONSIBLE_PERSON AS rPerson ON rPerson.REPAL_BOOK_ID = #{repalBookId}
- </if>
- LEFT JOIN REPAL_BILL AS bill ON bill.ID = tt.REPAL_BILL_ID
- WHERE
- tt.REPAL_BOOK_ID = #{repalBookId} AND bill.DELETED = 0
- <if test="startDateTime != null">
- AND tt.REMIND_TIME >= #{startDateTime}
- </if>
- <if test="endDateTime != null">
- AND tt.REMIND_TIME <![CDATA[<=]]> #{endDateTime}
- </if>
- <if test="userId != null">
- AND rPerson.USER_ID = #{userId}
- </if>
- GROUP BY tt.REMIND_TYPE
- </select>
- </mapper>
|