Ver Fonte

feat(house): 添加房屋状态查询功能

- 在 ASimplifiedHouseInfoDto 中新增 status 字段
- 实现房屋状态条件查询,支持空闲(1)、已租(2)、到期(3)状态筛选
- 为到期状态添加合同到期日期检查逻辑
- 更新房屋列表查询和总数统计的 SQL 条件
- 移除多余的空白行以优化代码格式
林仔 há 2 meses atrás
pai
commit
18ad3fd14a

+ 1 - 0
src/main/java/com/zksy/property/domain/dto/ASimplifiedHouseInfoDto.java

@@ -22,4 +22,5 @@ public class ASimplifiedHouseInfoDto {
     private Integer areaMax;
     private Integer pageNum;
     private Integer pageSize;
+    private Integer status;
 }

+ 37 - 1
src/main/resources/mapper/property/ASimplifiedHouseInfoMapper.xml

@@ -52,6 +52,25 @@
             <if test="entity.areaMax != null">
                 AND b.area &lt;= COALESCE(#{entity.areaMax}, b.area)
             </if>
+            <!-- 新增 status 条件:空查全部,1=空闲,2=已租,3=到期 -->
+            <if test="entity.status != null">
+                <choose>
+                    <when test="entity.status == 1">
+                        AND a.status = '空闲'
+                    </when>
+                    <when test="entity.status == 2">
+                        AND a.status = '已租'
+                    </when>
+                    <when test="entity.status == 3">
+                        AND EXISTS (
+                        SELECT 1
+                        FROM a_contract_info c
+                        WHERE c.simplified_house_id = a.id
+                        AND c.contract_expiration_date &lt; CURDATE()
+                        )
+                    </when>
+                </choose>
+            </if>
         </where>
         <if test="sortClause != null and sortClause != ''">
             ORDER BY ${sortClause}
@@ -63,7 +82,6 @@
         <if test="offset != null and limit != null">
             LIMIT #{offset}, #{limit}
         </if>
-
     </select>
     <select id="getListPageTotal" resultType="java.lang.Long">
         SELECT count(*)
@@ -91,6 +109,24 @@
             <if test="entity.areaMax != null">
                 AND b.area &lt;= COALESCE(#{entity.areaMax}, b.area)
             </if>
+            <if test="entity.status != null">
+                <choose>
+                    <when test="entity.status == 1">
+                        AND a.status = '空闲'
+                    </when>
+                    <when test="entity.status == 2">
+                        AND a.status = '已租'
+                    </when>
+                    <when test="entity.status == 3">
+                        AND EXISTS (
+                        SELECT 1
+                        FROM a_contract_info c
+                        WHERE c.simplified_house_id = a.id
+                        AND c.contract_expiration_date &lt; CURDATE()
+                        )
+                    </when>
+                </choose>
+            </if>
         </where>
     </select>
     <select id="getArrears" resultType="java.util.Map">