| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595 |
- <?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="communityServiceDaoImpl">
-
- <!-- 保存小区信息 add by wuxw 2018-07-03 -->
- <insert id="saveBusinessCommunityInfo" parameterType="Map">
- insert into business_community(community_id,b_id,name,address,city_code,
- nearby_landmarks,map_x,map_y,month,state,operate,community_area)
- values(#{communityId},#{bId},#{name},#{address},#{cityCode},
- #{nearbyLandmarks},#{mapX},#{mapY},#{month},#{state},#{operate},#{communityArea})
- </insert>
- <!-- 保存小区属性信息 add by wuxw 2018-07-03 -->
- <insert id="saveBusinessCommunityAttr" parameterType="Map">
- insert into business_community_attr(b_id,attr_id,community_id,spec_cd,value,month,operate)
- values(#{bId},#{attrId},#{communityId},#{specCd},#{value},#{month},#{operate})
- </insert>
- <!-- 保存小区照片信息 add by wuxw 2018-07-03 -->
- <insert id="saveBusinessCommunityPhoto" parameterType="Map">
- insert into business_community_photo(community_photo_id,b_id,community_id,community_photo_type_cd,photo,month,operate)
- values(#{communityPhotoId},#{bId},#{communityId},#{communityPhotoTypeCd},#{photo},#{month},#{operate})
- </insert>
- <!-- 查询小区信息(Business) add by wuxw 2018-07-03 -->
- <select id="getBusinessCommunityInfo" parameterType="Map" resultType="Map">
- select s.community_id,s.b_id,s.name,s.address,s.city_code,s.nearby_landmarks,
- s.map_x,s.map_y,s.operate,s.state,s.community_area communityArea,s.community_area
- from business_community s where 1 = 1
- <if test="operate != null and operate != ''">
- and s.operate = #{operate}
- </if>
- <if test="bId != null and bId !=''">
- and s.b_id = #{bId}
- </if>
- <if test="communityId != null and communityId != ''">
- and s.community_id = #{communityId}
- </if>
- </select>
- <!-- 查询小区属性信息(Business) add by wuxw 2018-07-03 -->
- <select id="getBusinessCommunityAttrs" parameterType="Map" resultType="Map">
- select sa.b_id,sa.attr_id,sa.community_id,sa.spec_cd,sa.value,sa.operate
- from business_community_attr sa where 1=1
- <if test="operate != null and operate != ''">
- and sa.operate = #{operate}
- </if>
- <if test="bId != null and bId !=''">
- and sa.b_id = #{bId}
- </if>
- <if test="communityId != null and communityId != ''">
- and sa.community_id = #{communityId}
- </if>
- <if test="attrId != null and attrId != ''">
- and sa.attr_id = #{attrId}
- </if>
- </select>
- <!-- 查询小区照片信息 add by wuxw 2018-07-03 -->
- <select id="getBusinessCommunityPhoto" parameterType="Map" resultType="Map">
- select sp.community_photo_id,sp.b_id,sp.community_id,sp.community_photo_type_cd,sp.photo,sp.operate
- from business_community_photo sp where 1=1
- <if test="bId != null and bId !=''">
- and sp.b_id = #{bId}
- </if>
- <if test="operate != null and operate != ''">
- and sp.operate = #{operate}
- </if>
- <if test="communityId != null and communityId != ''">
- and sp.community_id = #{communityId}
- </if>
- </select>
- <!-- 保存小区信息至 instance表中 add by wuxw 2018-07-03 -->
- <insert id="saveCommunityInfoInstance" parameterType="Map">
- insert into s_community(community_id,b_id,name,address,city_code,nearby_landmarks,map_x,map_y,status_cd,state,community_area)
- values(#{community_id},#{b_id},#{name},#{address},#{city_code},#{nearby_landmarks},#{map_x},#{map_y},'0',#{state},#{communityArea})
- </insert>
- <!-- 保存小区属性信息到 instance add by wuxw 2018-07-03 -->
- <insert id="saveCommunityAttrsInstance" parameterType="Map">
- insert into s_community_attr(b_id,attr_id,community_id,spec_cd,value,status_cd)
- select sa.b_id,sa.attr_id,sa.community_id,sa.spec_cd,sa.value,'0'
- from business_community_attr sa
- where sa.operate = 'ADD' and sa.b_id=#{bId}
- <if test="communityId != null and communityId != ''">
- and sa.community_id = #{communityId}
- </if>
- </insert>
-
- <!-- 保存 小区照片信息 instance add by wuxw 2018-07-03 -->
- <insert id="saveCommunityPhotoInstance" parameterType="Map">
- insert into s_community_photo(community_photo_id,b_id,community_id,community_photo_type_cd,photo,status_cd)
- select sp.community_photo_id,sp.b_id,sp.community_id,sp.community_photo_type_cd,sp.photo,'0'
- from business_community_photo sp
- where sp.operate = 'ADD' and sp.b_id=#{bId}
- <if test="communityId != null and communityId != ''">
- and sp.community_id = #{communityId}
- </if>
- </insert>
- <!-- 查询小区信息 add by wuxw 2018-07-03 -->
- <select id="getCommunityInfo" parameterType="Map" resultType="Map">
- select s.community_id,s.b_id,s.name,s.address,s.city_code,s.nearby_landmarks,s.map_x,s.map_y,s.status_cd,s.state
- from s_community s
- where 1=1
- <if test="statusCd != null and statusCd != ''">
- and s.status_cd = #{statusCd}
- </if>
- <if test="bId != null and bId !=''">
- and s.b_id = #{bId}
- </if>
- <if test="communityId != null and communityId !=''">
- and s.community_id = #{communityId}
- </if>
- </select>
- <!-- 查询小区属性信息 add by wuxw 2018-07-03 -->
- <select id="getCommunityAttrs" parameterType="Map" resultType="Map">
- select sa.b_id,sa.attr_id,sa.community_id,sa.spec_cd,sa.value,sa.status_cd
- from s_community_attr sa
- where
- 1=1
- <if test="statusCd != null and statusCd != ''">
- and sa.status_cd = #{statusCd}
- </if>
- <if test="bId != null and bId !=''">
- and sa.b_id = #{bId}
- </if>
- <if test="communityId != null and communityId !=''">
- and sa.community_id = #{communityId}
- </if>
- <if test="communityIds != null ">
- and sa.community_id in
- <foreach collection="communityIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="attrId != null and attrId != ''">
- and sa.attr_id = #{attrId}
- </if>
- </select>
- <!-- 查询小区照片信息 add by wuxw 2018-07-03 -->
- <select id="getCommunityPhoto" parameterType="Map" resultType="Map">
- select sp.community_photo_id,sp.b_id,sp.community_id,sp.community_photo_type_cd,sp.photo,sp.status_cd
- from s_community_photo sp
- where 1=1
- <if test="statusCd != null and statusCd != ''">
- and sp.status_cd = #{statusCd}
- </if>
- <if test="bId != null and bId !=''">
- and sp.b_id = #{bId}
- </if>
- <if test="communityId != null and communityId !=''">
- and sp.community_id = #{communityId}
- </if>
- </select>
- <!-- 修改小区信息 add by wuxw 2018-07-03 -->
- <update id="updateCommunityInfoInstance" parameterType="Map">
- update s_community s set s.status_cd = #{statusCd}
- <if test="newBId != null and newBId != ''">
- ,s.b_id = #{newBId}
- </if>
- <if test="name != null and name != ''">
- ,s.name = #{name}
- </if>
- <if test="address != null and address != ''">
- ,s.address = #{address}
- </if>
- <if test="cityCode != null and cityCode != ''">
- ,s.city_code = #{cityCode}
- </if>
- <if test="nearbyLandmarks != null and nearbyLandmarks != ''">
- ,s.nearby_landmarks = #{nearbyLandmarks}
- </if>
- <if test="mapX != null and mapX != ''">
- ,s.map_x = #{mapX}
- </if>
- <if test="mapY != null and mapY != ''">
- ,s.map_y = #{mapY}
- </if>
- <if test="state != null and state != ''">
- ,s.state = #{state}
- </if>
- <if test="communityArea != null and communityArea != ''">
- ,s.community_area = #{communityArea}
- </if>
- where 1=1
- <if test="bId != null and bId !=''">
- and s.b_id = #{bId}
- </if>
- <if test="communityId != null and communityId !=''">
- and s.community_id = #{communityId}
- </if>
- </update>
- <!-- 修改小区属性信息 add by wuxw 2018-07-03 -->
- <update id="updateCommunityAttrInstance" parameterType="Map">
- update s_community_attr sa set sa.status_cd = #{statusCd}
- <if test="newBId != null and newBId != ''">
- ,sa.b_id = #{newBId}
- </if>
- <if test="value != null and value != ''">
- ,sa.value = #{value}
- </if>
- where 1=1
- <if test="bId != null and bId !=''">
- and sa.b_id = #{bId}
- </if>
- <if test="communityId != null and communityId !=''">
- and sa.community_id = #{communityId}
- </if>
- <if test="specCd != null and specCd !=''">
- and sa.spec_cd = #{specCd}
- </if>
- <if test="attrId != null and attrId !=''">
- and sa.attr_id = #{attrId}
- </if>
- </update>
- <!-- 修改小区照片信息 add by wuxw 2018-07-03 -->
- <update id="updateCommunityPhotoInstance" parameterType="Map">
- update s_community_photo sp set sp.status_cd = #{statusCd}
- <if test="newBId != null and newBId != ''">
- ,sp.b_id = #{newBId}
- </if>
- <if test="communityPhotoTypeCd != null and communityPhotoTypeCd != ''">
- ,sp.community_photo_type_cd = #{communityPhotoTypeCd}
- </if>
- <if test="photo != null and photo != ''">
- ,sp.photo = #{photo}
- </if>
- where 1=1
- <if test="bId != null and bId !=''">
- and sp.b_id = #{bId}
- </if>
- <if test="communityId != null and communityId !=''">
- and sp.community_id = #{communityId}
- </if>
- <if test="communityPhotoId != null and communityPhotoId !=''">
- and sp.community_photo_id = #{communityPhotoId}
- </if>
- </update>
-
- <!--小区成员加入 add by wuxw 2018-10-27 saveBusinessCommunityMember-->
- <insert id="saveBusinessCommunityMember" parameterType="Map">
- insert into business_community_member(community_member_id,b_id,community_id,member_id,member_type_cd,month,operate,audit_status_cd)
- values(#{communityMemberId},#{bId},#{communityId},#{memberId},#{memberTypeCd},#{month},#{operate},#{auditStatusCd})
- </insert>
- <!-- 小区成员加入 instance表中 add by wuxw 2018-10-27 -->
- <insert id="saveCommunityMemberInstance" parameterType="Map">
- insert into s_community_member(community_member_id,b_id,community_id,member_id,member_type_cd,status_cd,audit_status_cd)
- select ms.community_member_id,ms.b_id,ms.community_id,ms.member_id,ms.member_type_cd,'0',ms.audit_status_cd
- from business_community_member ms where
- ms.operate = 'ADD' and ms.b_id=#{bId}
- <if test="communityId != null and communityId != ''">
- and ms.community_id = #{communityId}
- </if>
- </insert>
- <!-- 查询小区成员 add by wuxw 2018-10-27 getBusinessCommunityMember-->
- <select id="getBusinessCommunityMember" parameterType="Map" resultType="Map">
- select ms.community_member_id,ms.b_id,ms.community_id,ms.member_id,ms.member_type_cd,ms.operate,ms.audit_status_cd
- from business_community_member ms where 1 = 1
- <if test="operate != null and operate != ''">
- and ms.operate = #{operate}
- </if>
- <if test="bId != null and bId !=''">
- and ms.b_id = #{bId}
- </if>
- <if test="communityId != null and communityId != ''">
- and ms.community_id = #{communityId}
- </if>
- </select>
- <!-- 查询小区成员 add by wuxw 2018-07-03 -->
- <select id="getCommunityMember" parameterType="Map" resultType="Map">
- select ms.community_member_id , ms.b_id,ms.community_id,ms.member_id,ms.member_type_cd,ms.status_cd,ms.audit_status_cd,
- ms.community_member_id communityMemberId ,ms.b_id bId,ms.community_id communityId,ms.member_id memberId,ms.member_type_cd memberTypeCd,ms.status_cd statusCd,
- ms.audit_status_cd auditStatusCd,
- (CASE
- WHEN ms.audit_status_cd='1000'
- THEN '待审核'
- WHEN ms.audit_status_cd = '1100'
- THEN '审核完成'
- ELSE
- '审核拒绝'
- END) stateName
- <if test="needCommunityInfo == true">
- ,sc.name
- </if>
- from s_community_member ms
- <if test="needCommunityInfo == true">
- ,s_community sc,
- s_community_member msc
- </if>
- where 1=1
- <if test="needCommunityInfo == true">
- and sc.`community_id` = ms.`community_id`
- AND sc.`status_cd` = '0'
- and sc.state='1100'
- </if>
- <if test="statusCd != null and statusCd != ''">
- and ms.status_cd = #{statusCd}
- </if>
- <if test="bId != null and bId !=''">
- and ms.b_id = #{bId}
- </if>
- <if test="communityMemberId != null and communityMemberId !=''">
- and ms.community_member_id = #{communityMemberId}
- </if>
- <if test="memberId != null and memberId != '' and needCommunityInfo == true">
- AND ms.`community_id` = msc.`community_id`
- and msc.member_id = #{memberId}
- and msc.status_cd = '0'
- </if>
- <if test="memberId != null and memberId != '' and needCommunityInfo == false">
- and ms.member_id = #{memberId}
- </if>
- <if test="subMemberId != null and subMemberId != ''">
- and ms.member_id = #{subMemberId}
- </if>
- <if test="noAuditEnterCommunity == true">
- and ms.member_type_cd not in ('390001200003','390001200005','390001200000')
- </if>
- <if test="memberTypeCd != null and memberTypeCd != ''">
- and ms.member_type_cd = #{memberTypeCd}
- </if>
- <if test="auditStatusCd != null and auditStatusCd != ''">
- and ms.audit_status_cd = #{auditStatusCd}
- </if>
- <if test="communityId != null and communityId != ''">
- and ms.community_id = #{communityId}
- </if>
- <if test="communityName != null and communityName != '' and needCommunityInfo == true">
- and sc.name like concat('%',#{communityName},'%')
- </if>
- <if test="needCommunityInfo == true">
- group by ms.community_id
- </if>
- order by ms.create_time desc
- <if test="page != -1 and page != null">
- limit #{page},#{row}
- </if>
- </select>
- <!-- 修改小区成员 add by wuxw 2018-07-03 -->
- <update id="updateCommunityMemberInstance" parameterType="Map">
- update s_community_member ms set ms.status_cd = #{statusCd}
- <if test="newBId != null and newBId != ''">
- ,ms.b_id = #{newBId}
- </if>
- <if test="auditStatusCd !=null and auditStatusCd !=''">
- ,ms.audit_status_cd = #{auditStatusCd}
- </if>
- where 1=1
- <if test="bId != null and bId !=''">
- and ms.b_id = #{bId}
- </if>
- <if test="communityMemberId != null and communityMemberId !=''">
- and ms.community_member_id = #{communityMemberId}
- </if>
- </update>
- <!-- 查询小区成员 add by wuxw 2018-07-03 -->
- <select id="getCommunityMemberCount" parameterType="Map" resultType="Map">
- select ms.community_id,count(1) count
- from s_community_member ms
- <if test="needCommunityInfo == true">
- ,s_community sc,
- s_community_member msc
- </if>
- where 1=1
- <if test="needCommunityInfo == true">
- and sc.`community_id` = ms.`community_id`
- AND sc.`status_cd` = '0'
- and sc.state='1100'
- </if>
- <if test="statusCd != null and statusCd != ''">
- and ms.status_cd = #{statusCd}
- </if>
- <if test="bId != null and bId !=''">
- and ms.b_id = #{bId}
- </if>
- <if test="communityMemberId != null and communityMemberId !=''">
- and ms.community_member_id = #{communityMemberId}
- </if>
- <if test="memberId != null and memberId != '' and needCommunityInfo == true">
- AND ms.`community_id` = msc.`community_id`
- and msc.member_id = #{memberId}
- and msc.status_cd = '0'
- </if>
- <if test="memberId != null and memberId != '' and needCommunityInfo == false">
- and ms.member_id = #{memberId}
- </if>
- <if test="subMemberId != null and subMemberId != ''">
- and ms.member_id = #{subMemberId}
- </if>
- <if test="noAuditEnterCommunity == true">
- and ms.member_type_cd not in ('390001200003','390001200005','390001200000')
- </if>
- <if test="memberTypeCd != null and memberTypeCd != ''">
- and ms.member_type_cd = #{memberTypeCd}
- </if>
- <if test="auditStatusCd != null and auditStatusCd != ''">
- and ms.audit_status_cd = #{auditStatusCd}
- </if>
- <if test="auditStatusCds != null and auditStatusCds != null">
- and ms.audit_status_cd in
- <foreach collection="auditStatusCds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="communityId != null and communityId != ''">
- and ms.community_id = #{communityId}
- </if>
- <if test="communityName != null and communityName != '' and needCommunityInfo == true">
- and sc.name like concat('%',#{communityName},'%')
- </if>
- <if test="needCommunityInfo == true">
- group by ms.community_id
- </if>
- </select>
- <!-- 查询小区信息 add by wuxw 2018-07-03 -->
- <select id="getCommunityInfoNew" parameterType="Map" resultType="Map">
- select t.address,t.nearby_landmarks,t.nearby_landmarks nearbyLandmarks,
- t.city_code,t.city_code cityCode,t.name,t.status_cd,t.status_cd statusCd,
- t.community_id,t.community_id communityId,t.b_id,t.b_id bId,t.map_y,t.map_y mapY,
- t.map_x,t.map_x mapX,t.state,(CASE
- WHEN t.state='1000'
- THEN '待审核'
- WHEN t.state = '1100'
- THEN '审核完成'
- ELSE
- '审核拒绝'
- END) stateName,ca.area_code areaCode,ca.area_name areaName,
- ca.parent_area_code parentAreaCode,ca.parent_area_name parentAreaName,
- t.community_area communityArea
- from s_community t,city_area ca
- <if test="memberId !=null and memberId !=''">
- ,s_community_member cm
- </if>
- where 1 =1
- and t.city_code = ca.area_code
- and ca.status_cd = '0'
- <if test="address !=null and address != ''">
- and t.address= #{address}
- </if>
- <if test="nearbyLandmarks !=null and nearbyLandmarks != ''">
- and t.nearby_landmarks= #{nearbyLandmarks}
- </if>
- <if test="cityCode !=null and cityCode != ''">
- and t.city_code= #{cityCode}
- </if>
- <if test="name !=null and name != ''">
- and t.name like concat('%',#{name},'%')
- </if>
- <if test="statusCd !=null and statusCd != ''">
- and t.status_cd= #{statusCd}
- </if>
- <if test="communityId !=null and communityId != ''">
- and t.community_id= #{communityId}
- </if>
- <if test="communityIds !=null">
- and t.community_id in
- <foreach collection="communityIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="bId !=null and bId != ''">
- and t.b_id= #{bId}
- </if>
- <if test="mapY !=null and mapY != ''">
- and t.map_y= #{mapY}
- </if>
- <if test="mapX !=null and mapX != ''">
- and t.map_x= #{mapX}
- </if>
- <if test="state !=null and state != ''">
- and t.state= #{state}
- </if>
- <if test="memberId !=null and memberId !=''">
- and cm.community_id = t.community_id
- and cm.member_id = #{memberId}
- and cm.status_cd = '0'
- </if>
- <if test="memberId !=null and memberId !='' and auditStatusCd != null and auditStatusCd !=''">
- and cm.audit_status_cd = #{auditStatusCd}
- </if>
- <if test="notInCommunityId != null ">
- and t.community_id not in
- <foreach collection="notInCommunityId" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- group by t.community_id
- <if test="page != -1 and page != null ">
- limit #{page}, #{row}
- </if>
- </select>
- <!-- 查询小区数量 add by wuxw 2018-07-03 -->
- <select id="queryCommunitysCount" parameterType="Map" resultType="Map">
- select count(DISTINCT(t.community_id)) count
- from s_community t,city_area ca
- <if test="memberId !=null and memberId !=''">
- ,s_community_member cm
- </if>
- where 1 =1
- and t.city_code = ca.area_code
- and ca.status_cd = '0'
- <if test="address !=null and address != ''">
- and t.address= #{address}
- </if>
- <if test="nearbyLandmarks !=null and nearbyLandmarks != ''">
- and t.nearby_landmarks= #{nearbyLandmarks}
- </if>
- <if test="cityCode !=null and cityCode != ''">
- and t.city_code= #{cityCode}
- </if>
- <if test="name !=null and name != ''">
- and t.name like concat('%',#{name},'%')
- </if>
- <if test="statusCd !=null and statusCd != ''">
- and t.status_cd= #{statusCd}
- </if>
- <if test="communityId !=null and communityId != ''">
- and t.community_id= #{communityId}
- </if>
- <if test="communityIds !=null">
- and t.community_id in
- <foreach collection="communityIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="bId !=null and bId != ''">
- and t.b_id= #{bId}
- </if>
- <if test="mapY !=null and mapY != ''">
- and t.map_y= #{mapY}
- </if>
- <if test="mapX !=null and mapX != ''">
- and t.map_x= #{mapX}
- </if>
- <if test="state !=null and state != ''">
- and t.state= #{state}
- </if>
- <if test="memberId !=null and memberId !=''">
- and cm.community_id = t.community_id
- and cm.member_id = #{memberId}
- and cm.status_cd = '0'
- </if>
- <if test="memberId !=null and memberId !='' and auditStatusCd != null and auditStatusCd !=''">
- and cm.audit_status_cd = #{auditStatusCd}
- </if>
- <if test="notInCommunityId != null ">
- and t.community_id not in
- <foreach collection="notInCommunityId" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- </select>
- </mapper>
|