Procházet zdrojové kódy

优化 成员查询功能

java110 před 5 roky
rodič
revize
4c1f9f089d

+ 61 - 16
java110-db/src/main/resources/mapper/community/CommunityServiceDaoImplMapper.xml

@@ -3,7 +3,7 @@
         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,
@@ -18,7 +18,8 @@
     </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)
+        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>
 
@@ -76,7 +77,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,state,community_area)
+        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>
 
@@ -90,13 +92,13 @@
             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}
+        where sp.operate = 'ADD' and sp.b_id=#{bId}
         <if test="communityId != null and communityId != ''">
             and sp.community_id = #{communityId}
         </if>
@@ -128,7 +130,8 @@
         v.value_name valueName,
         s.list_show listShow
         from s_community_attr sa
-        left join attr_spec s on sa.spec_cd = s.spec_cd and s.status_cd = '0' and s.table_name = 'building_community_attr'
+        left join attr_spec s on sa.spec_cd = s.spec_cd and s.status_cd = '0' and s.table_name =
+        'building_community_attr'
         left join attr_value v on sa.`value` = v.`value` and sa.spec_cd = v.spec_cd and v.status_cd = '0'
         where
         1=1
@@ -170,7 +173,6 @@
     </select>
 
 
-
     <!-- 修改小区信息 add by wuxw 2018-07-03 -->
     <update id="updateCommunityInfoInstance" parameterType="Map">
         update s_community s set s.status_cd = #{statusCd}
@@ -260,17 +262,18 @@
         </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)
+        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)
+        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}
@@ -281,7 +284,8 @@
 
     <!-- 查询小区成员 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
+        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}
@@ -297,8 +301,10 @@
 
     <!-- 查询小区成员  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,
+        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'
@@ -455,7 +461,7 @@
 
     <!-- 查询小区信息 add by wuxw 2018-07-03 -->
     <select id="getCommunityInfoNew" parameterType="Map" resultType="Map">
-        select  t.address,t.nearby_landmarks,t.nearby_landmarks nearbyLandmarks,
+        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
@@ -533,10 +539,9 @@
     </select>
 
 
-
     <!-- 查询小区数量 add by wuxw 2018-07-03 -->
     <select id="queryCommunitysCount" parameterType="Map" resultType="Map">
-        select  count(DISTINCT(t.community_id)) count
+        select count(DISTINCT(t.community_id)) count
         from s_community t,city_area ca
         <if test="memberId !=null and memberId !=''">
             ,s_community_member cm
@@ -597,4 +602,44 @@
 
 
     </select>
+    <!-- 查询商户小区 -->
+    <select id="getStoreCommunitys" parameterType="Map" resultType="Map">
+        SELECT
+        sc.`community_id` communityId,
+        sc.`name`,
+        sc.`address`,
+        sc.`nearby_landmarks` nearbyLandmarks,
+        sc.`city_code` cityCode,
+        sc.`map_x` mapX,
+        sc.`map_y` mapY,
+        scm.`community_member_id` communityMemberId,
+        scm.`member_id` memberId,
+        scm.`member_type_cd` memberTypeCd,
+        scm.audit_status_cd auditStatusCd,
+        scm.`status_cd` statusCd,
+        ca.area_name areaName,
+        ca.parent_area_name cityName,
+        ca1.parent_area_name provName,
+        sc.community_area communityArea
+        FROM
+        s_community sc,
+        s_community_member scm,
+        city_area ca,
+        city_area ca1
+        WHERE
+        sc.`community_id` = scm.`community_id`
+        AND sc.`status_cd` = '0'
+        and sc.city_code = ca.area_code
+        and ca.parent_area_code = ca1.area_code
+        AND scm.`member_id` = #memberId#
+        AND scm.`member_type_cd` = #memberTypeCd#
+        AND scm.`status_cd` = '0'
+        <if test="auditStatusCd ==null or auditStatusCd ==''">
+            and scm.audit_status_cd in ('1000', '1100','1200')
+        </if>
+        <if test="auditStatusCd !=null and auditStatusCd !=''">
+            and scm.audit_status_cd = #auditStatusCd#
+        </if>
+        group by sc.community_id
+    </select>
 </mapper>

+ 11 - 2
java110-interface/src/main/java/com/java110/intf/community/ICommunityInnerServiceSMO.java

@@ -28,7 +28,6 @@ public interface ICommunityInnerServiceSMO {
     /**
      * <p>查询小区楼信息</p>
      *
-     *
      * @param communityDto 数据对象分享
      * @return CommunityDto 对象数据
      */
@@ -53,6 +52,16 @@ public interface ICommunityInnerServiceSMO {
     @RequestMapping(value = "/getCommunityMembers", method = RequestMethod.POST)
     List<CommunityMemberDto> getCommunityMembers(@RequestBody CommunityMemberDto communityMemberDto);
 
+
+    /**
+     * 查询商户入驻小区
+     *
+     * @param communityMemberDto 小区成员数据封装
+     * @return CommunityMemberDto 数据
+     */
+    @RequestMapping(value = "/getStoreCommunitys", method = RequestMethod.POST)
+    List<CommunityDto> getStoreCommunitys(@RequestBody CommunityMemberDto communityMemberDto);
+
     /**
      * 查询小区成员数量
      *
@@ -65,7 +74,6 @@ public interface ICommunityInnerServiceSMO {
     /**
      * <p>查询小区楼信息</p>
      *
-     *
      * @param communityAttrDto 数据对象分享
      * @return CommunityDto 对象数据
      */
@@ -81,4 +89,5 @@ public interface ICommunityInnerServiceSMO {
     @RequestMapping(value = "/getCommunityAttrsCount", method = RequestMethod.POST)
     int getCommunityAttrsCount(@RequestBody CommunityAttrDto communityAttrDto);
 
+
 }

+ 34 - 2
service-community/src/main/java/com/java110/community/api/CommunitysApi.java

@@ -15,20 +15,52 @@
  */
 package com.java110.community.api;
 
+import com.java110.community.bmo.community.IQueryStoreCommunitys;
+import com.java110.dto.CommunityMemberDto;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 /**
  * 小区相关对外提供接口类
- *
+ * <p>
  * 功能包括:
  * 商户小区查询接口
  *
  * @desc add by 吴学文 8:30
- *
+ * <p>
  * 文档参考 : http://www.homecommunity.cn/
  */
 @RestController
 @RequestMapping(value = "/communitys")
 public class CommunitysApi {
+
+    @Autowired
+    private IQueryStoreCommunitys queryStoreCommunitysImpl;
+
+
+    /**
+     * 查询商户入驻小区
+     *
+     * @param memberId
+     * @param memberTypeCd
+     * @param auditStatusCd
+     * @return
+     * @ServiceCode /communitys/queryStoreCommunitys
+     * @Path /app/communitys/queryStoreCommunitys
+     */
+    @RequestMapping(value = "/queryStoreCommunitys", method = RequestMethod.GET)
+    public ResponseEntity<String> queryStoreCommunitys(@RequestParam(value = "memberId") String memberId,
+                                                       @RequestParam(value = "memberTypeCd") String memberTypeCd,
+                                                       @RequestParam(value = "auditStatusCd", required = false) String auditStatusCd) {
+
+        CommunityMemberDto communityMemberDto = new CommunityMemberDto();
+        communityMemberDto.setMemberId(memberId);
+        communityMemberDto.setMemberTypeCd(memberTypeCd);
+        communityMemberDto.setAuditStatusCd(auditStatusCd);
+        return queryStoreCommunitysImpl.query(communityMemberDto);
+    }
 }

+ 36 - 0
service-community/src/main/java/com/java110/community/bmo/community/IQueryStoreCommunitys.java

@@ -0,0 +1,36 @@
+package com.java110.community.bmo.community;/*
+ * Copyright 2017-2020 吴学文 and java110 team.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import com.java110.dto.CommunityMemberDto;
+import org.springframework.http.ResponseEntity;
+
+/**
+ * 查询 商户入驻成功的小区信息
+ * <p>
+ * add by 吴学文 2020-12-23
+ * <p>
+ * 文档参考:http://www.homecommunity.cn
+ */
+public interface IQueryStoreCommunitys {
+
+    /**
+     * 查询商户入驻 小区信息
+     *
+     * @param communityMemberDto 小区成员信息
+     * @return
+     */
+    ResponseEntity<String> query(CommunityMemberDto communityMemberDto);
+}

+ 47 - 0
service-community/src/main/java/com/java110/community/bmo/community/impl/QueryStoreCommunitysImpl.java

@@ -0,0 +1,47 @@
+/*
+ * Copyright 2017-2020 吴学文 and java110 team.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.java110.community.bmo.community.impl;
+
+import com.java110.community.bmo.community.IQueryStoreCommunitys;
+import com.java110.dto.CommunityMemberDto;
+import com.java110.dto.community.CommunityDto;
+import com.java110.intf.community.ICommunityInnerServiceSMO;
+import com.java110.vo.ResultVo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 商户小区 查询实现类
+ * <p>
+ * add by 吴学文 2020-12-23
+ * <p>
+ * 文档参考:http://www.homecommunity.cn
+ */
+@Service
+public class QueryStoreCommunitysImpl implements IQueryStoreCommunitys {
+
+    @Autowired
+    private ICommunityInnerServiceSMO communityInnerServiceSMOImpl;
+
+    @Override
+    public ResponseEntity<String> query(CommunityMemberDto communityMemberDto) {
+        List<CommunityDto> communityDtos = communityInnerServiceSMOImpl.getStoreCommunitys(communityMemberDto);
+        return ResultVo.createResponseEntity(communityDtos);
+    }
+}

+ 1 - 0
service-community/src/main/java/com/java110/community/dao/ICommunityServiceDao.java

@@ -264,4 +264,5 @@ public interface ICommunityServiceDao {
     int getCommunityAttrsCount(Map info);
 
 
+    List<Map> getStoreCommunitys(Map beanCovertMap);
 }

+ 9 - 0
service-community/src/main/java/com/java110/community/dao/impl/CommunityServiceDaoImpl.java

@@ -480,4 +480,13 @@ public class CommunityServiceDaoImpl extends BaseServiceDao implements ICommunit
         return Integer.parseInt(businessCommunityInfos.get(0).get("count").toString());
     }
 
+    @Override
+    public List<Map> getStoreCommunitys(Map info) {
+        logger.debug("查询小区信息 入参 info : {}", info);
+
+        List<Map> businessCommunityInfos = sqlSessionTemplate.selectList("communityServiceDaoImpl.getStoreCommunitys", info);
+
+        return businessCommunityInfos;
+    }
+
 }

+ 32 - 0
service-community/src/main/java/com/java110/community/smo/impl/CommunityInnerServiceSMOImpl.java

@@ -49,6 +49,38 @@ public class CommunityInnerServiceSMOImpl extends BaseServiceSMO implements ICom
         return BeanConvertUtil.covertBeanList(communityMembers, CommunityMemberDto.class);
     }
 
+    @Override
+    public List<CommunityDto> getStoreCommunitys(CommunityMemberDto communityMemberDto) {
+        List<Map> communityMembers = communityServiceDaoImpl.getStoreCommunitys(BeanConvertUtil.beanCovertMap(communityMemberDto));
+        List<CommunityDto> communitys = BeanConvertUtil.covertBeanList(communityMembers, CommunityDto.class);
+
+        List<String> communityIds = new ArrayList<>();
+
+        if (communitys == null || communitys.size() < 1) {
+            return communitys;
+        }
+        for (CommunityDto tmpCommunityDto : communitys) {
+            communityIds.add(tmpCommunityDto.getCommunityId());
+        }
+        Map info = new HashMap();
+        info.put("communityIds", communityIds.toArray(new String[communityIds.size()]));
+        List<CommunityAttrDto> communityAttrDtos = BeanConvertUtil.covertBeanList(communityServiceDaoImpl.getCommunityAttrs(info), CommunityAttrDto.class);
+
+        if (communityAttrDtos == null || communityAttrDtos.size() < 1) {
+            return communitys;
+        }
+        for (CommunityDto tmpCommunityDto : communitys) {
+            List<CommunityAttrDto> tmpCommunityAttrDtos = new ArrayList<>();
+            for (CommunityAttrDto communityAttrDto : communityAttrDtos) {
+                if (tmpCommunityDto.getCommunityId().equals(communityAttrDto.getCommunityId())) {
+                    tmpCommunityAttrDtos.add(communityAttrDto);
+                }
+            }
+            tmpCommunityDto.setCommunityAttrDtos(tmpCommunityAttrDtos);
+        }
+        return communitys;
+    }
+
     @Override
     public int getCommunityMemberCount(@RequestBody CommunityMemberDto communityMemberDto) {
         logger.debug("getCommunityMemberCount:{}", JSONObject.toJSONString(communityMemberDto));

+ 7 - 2
service-front/src/main/java/com/java110/front/smo/impl/FrontCommunityServiceSMOImpl.java

@@ -60,14 +60,19 @@ public class FrontCommunityServiceSMOImpl extends BaseComponentSMO implements IC
         paramIn.put("memberId", storeId);
         paramIn.put("memberTypeCd", MappingCache.getValue(MappingConstant.DOMAIN_STORE_TYPE_2_COMMUNITY_MEMBER_TYPE, storeTypeCd));
         paramIn.putAll(_paramObj);
+//        responseEntity = this.callCenterService(restTemplate, pd, "",
+//                ServiceConstant.SERVICE_API_URL + "/api/query.myCommunity.byMember" + mapToUrlParam(paramIn),
+//                HttpMethod.GET);
+
         responseEntity = this.callCenterService(restTemplate, pd, "",
-                ServiceConstant.SERVICE_API_URL + "/api/query.myCommunity.byMember" + mapToUrlParam(paramIn),
+                ServiceConstant.SERVICE_API_URL + "/api/communitys/queryStoreCommunitys" + mapToUrlParam(paramIn),
                 HttpMethod.GET);
 
         if (responseEntity.getStatusCode() != HttpStatus.OK) {
             return responseEntity;
         }
-        JSONArray tmpCommunitys = JSONObject.parseObject(responseEntity.getBody().toString()).getJSONArray("communitys");
+        //JSONArray tmpCommunitys = JSONObject.parseObject(responseEntity.getBody().toString()).getJSONArray("communitys");
+        JSONArray tmpCommunitys = JSONObject.parseObject(responseEntity.getBody().toString()).getJSONArray("data");
         freshCommunityAttr(tmpCommunitys);
         responseEntity = new ResponseEntity<String>(tmpCommunitys.toJSONString(),
                 HttpStatus.OK);