From df774e4fd262b0a39e52152f166ccddb2aa9f90e Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期日, 11 十月 2020 23:44:43 +0800
Subject: [PATCH] 优化代码

---
 java110-db/src/main/resources/mapper/community/CommunityServiceDaoImplMapper.xml |  256 ++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 243 insertions(+), 13 deletions(-)

diff --git a/java110-db/src/main/resources/mapper/community/CommunityServiceDaoImplMapper.xml b/java110-db/src/main/resources/mapper/community/CommunityServiceDaoImplMapper.xml
index 207804c..9115934 100644
--- a/java110-db/src/main/resources/mapper/community/CommunityServiceDaoImplMapper.xml
+++ b/java110-db/src/main/resources/mapper/community/CommunityServiceDaoImplMapper.xml
@@ -6,8 +6,8 @@
     
     <!-- 淇濆瓨灏忓尯淇℃伅 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,operate)
-        values(#{communityId},#{bId},#{name},#{address},#{cityCode},#{nearbyLandmarks},#{mapX},#{mapY},#{month},#{operate})
+        insert into business_community(community_id,b_id,name,address,city_code,nearby_landmarks,map_x,map_y,month,state,operate)
+        values(#{communityId},#{bId},#{name},#{address},#{cityCode},#{nearbyLandmarks},#{mapX},#{mapY},#{month},#{state},#{operate})
     </insert>
     <!-- 淇濆瓨灏忓尯灞炴�т俊鎭�  add by wuxw 2018-07-03 -->
     <insert id="saveBusinessCommunityAttr" parameterType="Map">
@@ -23,7 +23,7 @@
 
     <!-- 鏌ヨ灏忓尯淇℃伅锛圔usiness锛� 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
+        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
         from business_community s where 1 = 1
         <if test="operate != null and operate != ''">
             and s.operate = #{operate}
@@ -73,10 +73,8 @@
 
     <!-- 淇濆瓨灏忓尯淇℃伅鑷� 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)
-        select s.community_id,s.b_id,s.name,s.address,s.city_code,s.nearby_landmarks,s.map_x,s.map_y,'0'
-        from business_community s where 
-        s.operate = 'ADD' and s.b_id=#{bId}
+        insert into s_community(community_id,b_id,name,address,city_code,nearby_landmarks,map_x,map_y,status_cd,state)
+        values(#{community_id},#{b_id},#{name},#{address},#{city_code},#{nearby_landmarks},#{map_x},#{map_y},'0',#{state})
     </insert>
 
     <!-- 淇濆瓨灏忓尯灞炴�т俊鎭埌 instance add by wuxw 2018-07-03 -->
@@ -85,6 +83,9 @@
         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 -->
@@ -93,12 +94,15 @@
         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
+        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 != ''">
@@ -176,6 +180,9 @@
         <if test="mapY != null and mapY != ''">
             ,s.map_y = #{mapY}
         </if>
+        <if test="state != null and state != ''">
+            ,s.state = #{state}
+        </if>
         where 1=1
         <if test="bId != null and bId !=''">
             and s.b_id = #{bId}
@@ -247,6 +254,9 @@
         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-->
@@ -267,11 +277,31 @@
 
     <!-- 鏌ヨ灏忓尯鎴愬憳  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,
+        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
+        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>
@@ -282,8 +312,19 @@
         <if test="communityMemberId != null and communityMemberId !=''">
             and ms.community_member_id = #{communityMemberId}
         </if>
-        <if test="memberId != null and memberId != ''">
+        <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}
@@ -294,6 +335,16 @@
 
         <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>
 
@@ -318,9 +369,18 @@
 
     <!-- 鏌ヨ灏忓尯鎴愬憳  add by wuxw 2018-07-03 -->
     <select id="getCommunityMemberCount" parameterType="Map" resultType="Map">
-        select count(1) count
+        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>
@@ -331,9 +391,23 @@
         <if test="communityMemberId != null and communityMemberId !=''">
             and ms.community_member_id = #{communityMemberId}
         </if>
-        <if test="memberId != null and memberId != ''">
+        <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>
@@ -341,9 +415,165 @@
             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
+        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>

--
Gitblit v1.8.0