|
|
@@ -32,7 +32,7 @@
|
|
|
AND a.asset_type = #{entity.assetType}
|
|
|
</if>
|
|
|
<if test="entity.building != null and entity.building != ''">
|
|
|
- AND a.building = #{entity.building}
|
|
|
+ AND a.building LIKE CONCAT(#{entity.building}, '%')
|
|
|
</if>
|
|
|
<if test="entity.floor != null and entity.floor != ''">
|
|
|
AND a.floor LIKE CONCAT(#{entity.floor}, '%')
|
|
|
@@ -90,4 +90,37 @@
|
|
|
</if>
|
|
|
</where>
|
|
|
</select>
|
|
|
+ <select id="getArrears" resultType="java.util.Map">
|
|
|
+ SELECT
|
|
|
+ h.id AS id,
|
|
|
+ h.house_name AS houseName,
|
|
|
+ h.address AS address,
|
|
|
+ c.contract_number AS contractNumber,
|
|
|
+ c.contract_expiration_date AS contractExpirationDate,
|
|
|
+ r.end_date AS endDate,
|
|
|
+ NOW() AS nowAndDate
|
|
|
+ FROM
|
|
|
+ a_simplified_house_info h
|
|
|
+ JOIN
|
|
|
+ a_contract_info c ON h.id = c.simplified_house_id
|
|
|
+ JOIN (
|
|
|
+ -- 子查询:对每个合同,取最新一条“开始时间、结束时间非空”的收据
|
|
|
+ SELECT
|
|
|
+ contract_id,
|
|
|
+ end_date,
|
|
|
+ -- 按生成时间倒序,取第一条
|
|
|
+ ROW_NUMBER() OVER (PARTITION BY contract_id ORDER BY generation_date DESC) AS rn
|
|
|
+ FROM
|
|
|
+ a_receipt_info
|
|
|
+ WHERE
|
|
|
+ start_date IS NOT NULL
|
|
|
+ AND end_date IS NOT NULL
|
|
|
+ ) r ON c.id = r.contract_id AND r.rn = 1
|
|
|
+ WHERE
|
|
|
+ h.status = '已租'
|
|
|
+ AND c.contract_status = '有效'
|
|
|
+ AND r.end_date < c.contract_expiration_date AND r.end_date < NOW()
|
|
|
+ ORDER BY
|
|
|
+ h.id;
|
|
|
+ </select>
|
|
|
</mapper>
|