linwe
2024-08-09 8b7258c9427882bb1798f1502eaa35184c6e374e
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
<?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="org.springblade.modules.property.mapper.PropertyCompanyMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="propertyCompanyResultMap" type="org.springblade.modules.property.vo.PropertyCompanyVO">
        <result property="id"    column="id"    />
        <result property="deptId"    column="dept_id"    />
        <result property="name"    column="name"    />
        <result property="address"    column="address"    />
        <result property="socialCreditCode"    column="social_credit_code"    />
        <result property="province"    column="province"    />
        <result property="city"    column="city"    />
        <result property="area"    column="area"    />
        <result property="remark"    column="remark"    />
        <result property="createUser"    column="create_user"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateUser"    column="update_user"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isDeleted"    column="is_deleted"    />
        <result property="baseInfoScore"    column="base_info_score"    />
        <result property="operateinfoScore"    column="operateInfo_score"    />
        <result property="taxInfoScore"    column="tax_info_score"    />
        <result property="partyBuildingInfoScore"    column="party_building_info_score"    />
        <result property="goodCorporateScore"    column="good_corporate_score"    />
        <result property="goodProjectScore"    column="good_project_score"    />
        <result property="lllegalAndIrregularScore"    column="lllegal_and_irregular_score"    />
        <result property="evaluateScore"    column="evaluate_score"    />
        <result property="streetScore"    column="street_score"    />
        <result property="allScore"    column="all_score"    />
    </resultMap>
 
 
 
    <sql id="selectPropertyCompany">
        select
            id,
            name,
            address,
            social_credit_code,
            province_code,
            city_code,
            county_code,
            remark,
            create_user,
            create_time,
            update_user,
            update_time,
            is_deleted
        from
            jczz_property_company
    </sql>
 
 
    <!--自定义分页查询-->
    <select id="selectPropertyCompanyPage" resultMap="propertyCompanyResultMap">
        SELECT
        jpc.id,
        jpc.dept_id,
        jpc.NAME,
        jpc.address,
        jpc.social_credit_code,
        jpc.province,
        jpc.city,
        jpc.area,
        jpc.remark,
        jpc.create_user,
        jpc.create_time,
        jpc.update_user,
        jpc.update_time,
        jpc.is_deleted,
        jpc.base_info_score,
        jpc.operateInfo_score,
        jpc.tax_info_score,
        jpc.party_building_info_score,
        jpc.good_corporate_score,
        jpc.good_project_score,
        jpc.lllegal_and_irregular_score,
        jpc.evaluate_score,
        jpc.street_score,
        jpc.all_score,
        (
        SELECT
        GROUP_CONCAT( jd.`name` )
        FROM
        jczz_property_company_district jpcd
        LEFT JOIN jczz_district jd ON jpcd.district_id = jd.id
        WHERE
        jpcd.property_company_id = jpc.id
        ) districtNames
        FROM
        jczz_property_company jpc
        WHERE
        jpc.is_deleted = 0
        <if test="propertyCompany.name!=null and propertyCompany.name!=''">
            and jpc.name like concat('%',#{propertyCompany.name},'%')
        </if>
    </select>
 
    <!--物业公司列表查询(不分页)-->
    <select id="getPropertyCompanyList" resultType="org.springblade.modules.property.vo.PropertyCompanyVO">
        select * from jczz_property_company where is_deleted = 0
        <if test="propertyCompany.name!=null and propertyCompany.name!=''">
            and name like concat('%',#{propertyCompany.name},'%')
        </if>
    </select>
 
    <!--物业公司列表查询(不分页)-->
    <select id="getUserByPropertyCompany" resultType="java.util.Map">
        select
            bu.id,bu.real_name as name
        from blade_user bu
        left join blade_dept bd on bd.id = bu.dept_id and bd.is_deleted = 0
        left join jczz_property_company jpc on jpc.dept_id = bd.id and jpc.is_deleted = 0
        where bu.is_deleted = 0 and bu.real_name is not null
        and jpc.id = #{propertyCompany.id}
    </select>
 
    <!--查询对应的机构id集合-->
    <select id="getDeptListByCompanyId" resultType="java.lang.Long">
        select dept_id from jczz_property_company
        jpc where is_deleted = 0
        <choose>
            <when test="list != null and list.size()>0">
                and id in
                <foreach collection="list" item="id" separator ="," open="("  close=")">
                    #{id}
                </foreach>
            </when>
            <otherwise>
                and id in ('')
            </otherwise>
        </choose>
    </select>
 
 
 
    <select id="getUserCompayDistrict" resultType="org.springblade.modules.property.vo.PropertyCompanyVO">
 
        select
        jpc.id,
        jpc.name,
        jpc.address,
        jpc.social_credit_code,
        jpc.province_code,
        jpc.city_code,
        jpc.county_code,
        jpc.remark,
        jpc.create_user,
        jpc.create_time,
        jpc.update_user,
        jpc.update_time,
        jpc.is_deleted,
        jpcd.principal_phone,
        jpcd.principal
        from
        jczz_property_company jpc LEFT JOIN jczz_property_company_district jpcd on jpc.id=jpcd.property_company_id
        LEFT JOIN jczz_doorplate_address jda on jpcd.district_id=jda.aoi_code
        where jda.address_code=#{houseCode}
<!--        <where>-->
<!--            <if test="id != null "> and id = #{id}</if>-->
<!--            <if test="name != null  and name != ''"> and name = #{name}</if>-->
<!--            <if test="address != null  and address != ''"> and address = #{address}</if>-->
<!--            <if test="socialCreditCode != null  and socialCreditCode != ''"> and social_credit_code = #{socialCreditCode}</if>-->
<!--            <if test="provinceCode != null  and provinceCode != ''"> and province_code = #{provinceCode}</if>-->
<!--            <if test="cityCode != null  and cityCode != ''"> and city_code = #{cityCode}</if>-->
<!--            <if test="countyCode != null  and countyCode != ''"> and county_code = #{countyCode}</if>-->
<!--            <if test="remark != null  and remark != ''"> and remark = #{remark}</if>-->
<!--            <if test="createUser != null  and createUser != ''"> and create_user = #{createUser}</if>-->
<!--            <if test="createTime != null "> and create_time = #{createTime}</if>-->
<!--            <if test="updateUser != null  and updateUser != ''"> and update_user = #{updateUser}</if>-->
<!--            <if test="updateTime != null "> and update_time = #{updateTime}</if>-->
<!--            <if test="isDeleted != null "> and is_deleted = #{isDeleted}</if>-->
<!--        </where>-->
    </select>
 
    <!--物业公司详情map-->
    <resultMap id="propertyCompanyDetailMap" type="org.springblade.modules.property.vo.PropertyCompanyDetailVO" autoMapping="true">
        <id property="id" column="id"/>
        <collection property="districtUserVOS"  javaType="java.util.List"
                    ofType="org.springblade.modules.property.vo.PropertyDistrictUserVO" autoMapping="true">
            <id property="id" column="cid"/>
            <result property="name" column="real_name"/>
            <result property="phone" column="companyPersonPhone"/>
        </collection>
    </resultMap>
 
    <!--自定义详情查询-->
    <select id="getDetail" resultMap="propertyCompanyDetailMap">
        SELECT DISTINCT jpc.*,
                        jpcd.principal,
                        jpcd.principal_phone AS principalPhone,
                        bu.real_name,
                        bu.phone             AS companyPersonPhone
        FROM jczz_property_company jpc
                 LEFT JOIN jczz_property_company_district jpcd
                           ON jpcd.property_company_id = jpc.id and jpcd.is_deleted = 0
                 LEFT JOIN jczz_property_district_user jpdu ON jpcd.id = jpdu.property_company_district_id
                 LEFT JOIN blade_user bu ON locate(jpdu.user_id, bu.id) > 0 and bu.is_deleted = 0
        WHERE jpc.is_deleted = 0
          and bu.real_name is not null
          and jpc.id = #{propertyCompany.id}
    </select>
 
    <select id="getDetailVO" resultType="org.springblade.modules.property.vo.PropertyCompanyDetailVO">
        SELECT
            jpc.*
        FROM
            jczz_property_company jpc
        WHERE jpc.is_deleted = 0
          and jpc.id = #{propertyCompany.id}
    </select>
 
    <select id="getPropertyDistrictInfo" resultType="org.springblade.modules.property.vo.PropertyDistrictInfo">
 
    SELECT
        house.house_code as houseId,
        house.house_name as houseName,
        house.area as houseArea,
        district.name as districtName,
        district.id as districtId,
        company.id as id,
        company.dept_id as deptId,
        company.name as propertyCompanyName,
        charge.unit_price as unitPrice,
        charge.calculation_formula as payCalculationFormula,
        bdb.dict_value as payCalculationFormulaName
    FROM jczz_house house
    LEFT JOIN jczz_district district ON district.aoi_code = house.district_code
    LEFT JOIN jczz_property_charge charge ON charge.district_id = district.id
    LEFT JOIN jczz_property_company company ON company.dept_id = charge.property_id
    LEFT JOIN blade_dict_biz bdb ON bdb.dict_key = charge.pay_type
 
    WHERE house.is_deleted = 0 and bdb.code = 'payCalculationFormula'
    <if test="info.houseId != null and info.houseId !=''">
        AND house.house_code = #{info.houseId}
    </if>
    </select>
 
 
</mapper>