yanghb
2024-12-24 fe6e43d5e1144156d0ca4e9d6080c9821c25d97c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?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.zzg.system.mapper.state.StateAssetMapper">
    <select id="listAssetDetail" parameterType="com.zzg.system.domain.bo.AssetDetailBO"
            resultType="com.zzg.system.domain.vo.StateAssetDetailVO">
        SELECT DISTINCT t2.belonging_street_town as street,
        t1.status as projectStatus,
        t2.household_location as location,
        t2.compensation_type as compensationType,
        t2.real_estate_certificate_number as realstateCertificateNumber,
        t2.using_area_certificate_number as usingAreaCertificateNumber,
        t2.id as houseId,
        (SELECT STRING_AGG(owner_name, '|' ORDER BY owner_name) FROM state_household_owner WHERE state_household_id = t2.id) as owner_name,
        (select count(1) from state_household_owner where state_household_id = t2.id) as person_num,
        CASE
        WHEN t1.status = 0 THEN 2
        WHEN t1.status IN (1, 3) THEN 3
        ELSE t4.agreement_file_type
        END as agreementFileType
        FROM state_household t2
        LEFT JOIN
        state_project t1 ON t1.id = t2.state_project_id
        LEFT JOIN
        state_settlement t3 ON t2.id = t3.state_household_id
        LEFT JOIN
        state_agreement t4 ON t2.id = t4.state_household_id
        <where>
            t2.id IS NOT NULL
            and t2.del_flag = 0
            <if test="assetDetailBO != null">
                <if test="assetDetailBO.type != null">
                    <if test="assetDetailBO.type == 2">
                        AND t3.audit_status IS NOT NULL
                        AND t2.id IN (SELECT state_household_id FROM state_settlement WHERE audit_status IS NOT NULL)
                    </if>
                    <if test="assetDetailBO.type == 1">
                        AND t2.agreement_status IS NOT NULL
                        AND t2.id IN (SELECT state_household_id FROM state_agreement WHERE audit_status IS NOT NULL)
                    </if>
                </if>
                <if test="assetDetailBO.ownerName != null and assetDetailBO.ownerName != ''">
                    AND (SELECT STRING_AGG(owner_name, '|' ORDER BY owner_name) FROM state_household_owner WHERE state_household_id = t2.id) LIKE CONCAT('%', #{assetDetailBO.ownerName}, '%')
                </if>
                <if test="assetDetailBO.street != null and assetDetailBO.street != ''">
                    AND t2.belonging_street_town = #{assetDetailBO.street}
                </if>
                <if test="assetDetailBO.location != null and assetDetailBO.location != ''">
                    AND t2.household_location LIKE CONCAT('%', #{assetDetailBO.location}, '%')
                </if>
                <if test="assetDetailBO.projectId != null and assetDetailBO.projectId != ''">
                    AND t1.id = #{assetDetailBO.projectId}
                </if>
                <if test="assetDetailBO.compensationType != null and assetDetailBO.compensationType != 0">
                    AND t2.compensation_type = #{assetDetailBO.compensationType}
                </if>
                <if test="assetDetailBO.usingType != null and assetDetailBO.usingType != 0">
                    AND t2.house_using_type = #{assetDetailBO.usingType}
                </if>
                <if test="assetDetailBO.houseHoldNumber != null and assetDetailBO.houseHoldNumber != ''">
                    AND (t2.real_estate_certificate_number LIKE CONCAT('%', #{assetDetailBO.houseHoldNumber}, '%')
                    OR t2.using_area_certificate_number LIKE CONCAT('%', #{assetDetailBO.houseHoldNumber}, '%'))
                </if>
            </if>
        </where>
    </select>
 
</mapper>