Просмотр исходного кода

业主查询接口开发完成

wuxw лет назад: 7
Родитель
Сommit
34324a4bb8

+ 29 - 0
Api/src/main/java/com/java110/api/listener/owner/QueryOwnersListener.java

@@ -56,6 +56,12 @@ public class QueryOwnersListener extends AbstractServiceApiDataFlowListener {
         JSONObject reqJson = dataFlowContext.getReqJson();
         validateOwnerData(reqJson);
 
+
+        if (reqJson.containsKey("name")) {
+            queryByCondition(reqJson, dataFlowContext);
+            return;
+        }
+
         int row = reqJson.getInteger("row");
 
         ApiOwnerVo apiOwnerVo = new ApiOwnerVo();
@@ -74,6 +80,29 @@ public class QueryOwnersListener extends AbstractServiceApiDataFlowListener {
         dataFlowContext.setResponseEntity(responseEntity);
     }
 
+    /**
+     * 根据条件查询
+     *
+     * @param reqJson         查询信息
+     * @param dataFlowContext 上下文
+     */
+    private void queryByCondition(JSONObject reqJson, DataFlowContext dataFlowContext) {
+
+        int row = reqJson.getInteger("row");
+        ApiOwnerVo apiOwnerVo = new ApiOwnerVo();
+        int total = ownerInnerServiceSMOImpl.queryOwnerCountByCondition(BeanConvertUtil.covertBean(reqJson, OwnerDto.class));
+        apiOwnerVo.setTotal(total);
+        if (total > 0) {
+            List<OwnerDto> ownerDtoList = ownerInnerServiceSMOImpl.queryOwnersByCondition(BeanConvertUtil.covertBean(reqJson, OwnerDto.class));
+            apiOwnerVo.setOwners(BeanConvertUtil.covertBeanList(ownerDtoList, ApiOwnerDataVo.class));
+        }
+
+        apiOwnerVo.setRecords((int) Math.ceil((double) total / (double) row));
+
+        ResponseEntity<String> responseEntity = new ResponseEntity<String>(JSONObject.toJSONString(apiOwnerVo), HttpStatus.OK);
+        dataFlowContext.setResponseEntity(responseEntity);
+    }
+
     /**
      * 校验查询条件是否满足条件
      *

+ 10 - 0
CommunityService/src/main/java/com/java110/community/smo/impl/CommunityInnerServiceSMOImpl.java

@@ -6,6 +6,7 @@ import com.java110.community.dao.ICommunityServiceDao;
 import com.java110.core.base.smo.BaseServiceSMO;
 import com.java110.core.smo.community.ICommunityInnerServiceSMO;
 import com.java110.dto.CommunityMemberDto;
+import com.java110.dto.PageDto;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -32,6 +33,15 @@ public class CommunityInnerServiceSMOImpl extends BaseServiceSMO implements ICom
 
         logger.debug("communityMemberDto:{}", JSONObject.toJSONString(communityMemberDto));
 
+        //校验是否传了 分页信息
+
+        int page = communityMemberDto.getPage();
+
+        if (page != PageDto.DEFAULT_PAGE) {
+            communityMemberDto.setPage((page - 1) * communityMemberDto.getRow());
+            communityMemberDto.setRow(page * communityMemberDto.getRow());
+        }
+
         List<Map> communityMembers = communityServiceDaoImpl.getCommunityMembers(BeanConvertUtil.beanCovertMap(communityMemberDto));
         return BeanConvertUtil.covertBeanList(communityMembers, CommunityMemberDto.class);
     }

+ 18 - 0
UserService/src/main/java/com/java110/user/dao/IOwnerServiceDao.java

@@ -73,4 +73,22 @@ public interface IOwnerServiceDao {
      */
     int queryOwnersCount(Map info);
 
+
+    /**
+     * 查询业主总数
+     *
+     * @param info 业主信息
+     * @return 业主数量
+     */
+    int queryOwnersCountByCondition(Map info);
+
+    /**
+     * 查询业主信息(instance)
+     *
+     * @param info bId 信息
+     * @return List<Map>
+     * @throws DAOException DAO异常
+     */
+     List<Map> getOwnerInfoByCondition(Map info) throws DAOException;
+
 }

+ 34 - 0
UserService/src/main/java/com/java110/user/dao/impl/OwnerServiceDaoImpl.java

@@ -130,5 +130,39 @@ public class OwnerServiceDaoImpl extends BaseServiceDao implements IOwnerService
         return Integer.parseInt(businessOwnerInfos.get(0).get("count").toString());
     }
 
+    /**
+     * 查询业主数量
+     *
+     * @param info 业主信息
+     * @return 业主数量
+     */
+    @Override
+    public int queryOwnersCountByCondition(Map info) {
+        logger.debug("查询业主数据 入参 info : {}", info);
+
+        List<Map> businessOwnerInfos = sqlSessionTemplate.selectList("ownerServiceDaoImpl.queryOwnersCountByCondition", info);
+        if (businessOwnerInfos.size() < 1) {
+            return 0;
+        }
+
+        return Integer.parseInt(businessOwnerInfos.get(0).get("count").toString());
+    }
+
+    /**
+     * 查询业主信息(instance)
+     *
+     * @param info bId 信息
+     * @return List<Map>
+     * @throws DAOException DAO异常
+     */
+    @Override
+    public List<Map> getOwnerInfoByCondition(Map info) throws DAOException {
+        logger.debug("查询业主信息 入参 info : {}", info);
+
+        List<Map> businessOwnerInfos = sqlSessionTemplate.selectList("ownerServiceDaoImpl.getOwnerInfoByCondition", info);
+
+        return businessOwnerInfos;
+    }
+
 
 }

+ 67 - 10
UserService/src/main/java/com/java110/user/smo/impl/OwnerInnerServiceSMOImpl.java

@@ -2,6 +2,7 @@ package com.java110.user.smo.impl;
 
 
 import com.java110.common.constant.CommunityMemberTypeConstant;
+import com.java110.common.constant.StatusConstant;
 import com.java110.common.util.BeanConvertUtil;
 import com.java110.core.base.smo.BaseServiceSMO;
 import com.java110.core.smo.community.ICommunityInnerServiceSMO;
@@ -17,7 +18,9 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @ClassName FloorInnerServiceSMOImpl
@@ -42,18 +45,17 @@ public class OwnerInnerServiceSMOImpl extends BaseServiceSMO implements IOwnerIn
     @Override
     public List<OwnerDto> queryOwners(@RequestBody OwnerDto ownerDto) {
 
-        //校验是否传了 分页信息
-
-        int page = ownerDto.getPage();
-
-        if (page != PageDto.DEFAULT_PAGE) {
-            ownerDto.setPage((page - 1) * ownerDto.getRow());
-            ownerDto.setRow(page * ownerDto.getRow());
-        }
-
         //communityInnerServiceSMOImpl.getCommunityMembers()
+        //调用 小区服务查询 小区成员业主信息
+        CommunityMemberDto communityMemberDto = BeanConvertUtil.covertBean(ownerDto, CommunityMemberDto.class);
+        communityMemberDto.setMemberTypeCd(CommunityMemberTypeConstant.OWNER);
+        List<CommunityMemberDto> communityMemberDtos = communityInnerServiceSMOImpl.getCommunityMembers(communityMemberDto);
 
-        List<OwnerDto> owners = BeanConvertUtil.covertBeanList(ownerServiceDaoImpl.getOwnerInfo(BeanConvertUtil.beanCovertMap(ownerDto)), OwnerDto.class);
+        Map ownerInfo = new HashMap();
+        ownerInfo.put("ownerIds", getOwnerIds(communityMemberDtos));
+        ownerInfo.put("statusCd", StatusConstant.STATUS_CD_VALID);
+
+        List<OwnerDto> owners = BeanConvertUtil.covertBeanList(ownerServiceDaoImpl.getOwnerInfo(ownerInfo), OwnerDto.class);
 
         if (owners == null || owners.size() == 0) {
             return owners;
@@ -83,6 +85,21 @@ public class OwnerInnerServiceSMOImpl extends BaseServiceSMO implements IOwnerIn
         }
     }
 
+    /**
+     * 获取批量userId
+     *
+     * @param communityMemberDtos 小区楼信息
+     * @return 批量userIds 信息
+     */
+    private String[] getOwnerIds(List<CommunityMemberDto> communityMemberDtos) {
+        List<String> ownerIds = new ArrayList<String>();
+        for (CommunityMemberDto communityMemberDto : communityMemberDtos) {
+            ownerIds.add(communityMemberDto.getMemberId());
+        }
+
+        return ownerIds.toArray(new String[ownerIds.size()]);
+    }
+
     /**
      * 获取批量userId
      *
@@ -109,6 +126,46 @@ public class OwnerInnerServiceSMOImpl extends BaseServiceSMO implements IOwnerIn
 
     }
 
+    @Override
+    public int queryOwnerCountByCondition(OwnerDto ownerDto) {
+
+        //校验是否传了 分页信息
+
+        int page = ownerDto.getPage();
+
+        if (page != PageDto.DEFAULT_PAGE) {
+            ownerDto.setPage((page - 1) * ownerDto.getRow());
+            ownerDto.setRow(page * ownerDto.getRow());
+        }
+        return ownerServiceDaoImpl.queryOwnersCount(BeanConvertUtil.beanCovertMap(ownerDto));
+    }
+
+    @Override
+    public List<OwnerDto> queryOwnersByCondition(OwnerDto ownerDto) {
+//校验是否传了 分页信息
+
+        int page = ownerDto.getPage();
+
+        if (page != PageDto.DEFAULT_PAGE) {
+            ownerDto.setPage((page - 1) * ownerDto.getRow());
+            ownerDto.setRow(page * ownerDto.getRow());
+        }
+        List<OwnerDto> owners =  BeanConvertUtil.covertBeanList(
+                ownerServiceDaoImpl.getOwnerInfoByCondition(BeanConvertUtil.beanCovertMap(ownerDto)), OwnerDto.class);
+        if (owners == null || owners.size() == 0) {
+            return owners;
+        }
+
+        String[] userIds = getUserIds(owners);
+        //根据 userId 查询用户信息
+        List<UserDto> users = userInnerServiceSMOImpl.getUserInfo(userIds);
+
+        for (OwnerDto owner : owners) {
+            refreshOwner(owner, users);
+        }
+        return owners;
+    }
+
     public IUserInnerServiceSMO getUserInnerServiceSMOImpl() {
         return userInnerServiceSMOImpl;
     }

+ 1 - 1
java110-bean/src/main/java/com/java110/dto/CommunityMemberDto.java

@@ -5,7 +5,7 @@ import java.io.Serializable;
 /**
  * 小区成员dto
  */
-public class CommunityMemberDto implements Serializable {
+public class CommunityMemberDto extends PageDto implements Serializable {
 
     private String communityMemberId;
 

+ 7 - 7
java110-bean/src/main/java/com/java110/dto/OwnerDto.java

@@ -18,13 +18,13 @@ public class OwnerDto extends PageDto implements Serializable {
 
     private String roomId;
     private String sex;
-private String name;
-private String link;
-private String remark;
-private String ownerId;
-private String userId;
-private String age;
-private String memberId;
+    private String name;
+    private String link;
+    private String remark;
+    private String ownerId;
+    private String userId;
+    private String age;
+    private String memberId;
 
 
     private Date createTime;

+ 19 - 0
java110-core/src/main/java/com/java110/core/smo/owner/IOwnerInnerServiceSMO.java

@@ -39,4 +39,23 @@ public interface IOwnerInnerServiceSMO {
      */
     @RequestMapping(value = "/queryOwnersCount", method = RequestMethod.POST)
     int queryOwnersCount(@RequestBody OwnerDto ownerDto);
+
+    /**
+     * 查询<p>小区楼</p>总记录数 根据条件查询
+     * @param ownerDto 数据对象分享
+     * @return 小区下的小区楼记录数
+     */
+    @RequestMapping(value = "/queryOwnerCountByCondition", method = RequestMethod.POST)
+    int queryOwnerCountByCondition(@RequestBody OwnerDto ownerDto);
+
+
+    /**
+     * <p>查询小区楼信息</p> 根据条件查询
+     *
+     *
+     * @param ownerDto 数据对象分享 根据条件查询
+     * @return OwnerDto 对象数据
+     */
+    @RequestMapping(value = "/queryOwnersByCondition", method = RequestMethod.POST)
+    List<OwnerDto> queryOwnersByCondition(@RequestBody OwnerDto ownerDto);
 }

+ 3 - 0
java110-db/src/main/resources/mapper/community/CommunityServiceDaoImplMapper.xml

@@ -302,6 +302,9 @@
         <if test="communityId != null and communityId != ''">
             and ms.community_id = #{communityId}
         </if>
+        <if test="page != -1 and page != null">
+            limit #{page},#{row}
+        </if>
     </select>
 
     <!-- 修改小区成员 add by wuxw 2018-07-03 -->

+ 102 - 4
java110-db/src/main/resources/mapper/owner/OwnerServiceDaoImplMapper.xml

@@ -128,7 +128,13 @@ where 1 =1
 </if> 
 <if test="memberId !=null and memberId != ''">
    and t.member_id= #{memberId}
-</if> 
+</if>
+        <if test="ownerIds != null and ownerIds != ''">
+            and t.owner_id in
+            <foreach collection="ownerIds" item="item" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
 <if test="page != -1 and page != null ">
    limit #{page}, #{row}
 </if> 
@@ -176,9 +182,8 @@ and t.member_id= #{memberId}
 
     <!-- 查询业主数量 add by wuxw 2018-07-03 -->
      <select id="queryOwnersCount" parameterType="Map" resultType="Map">
-        select  count(1) count 
-from building_owner t 
-where 1 =1 
+        select  count(1) count
+         FROM building_owner t
 <if test="sex !=null and sex != ''">
    and t.sex= #{sex}
 </if> 
@@ -213,4 +218,97 @@ where 1 =1
 
      </select>
 
+
+    <!-- 查询业主数量 add by wuxw 2018-07-03 -->
+    <select id="queryOwnersCountByCondition" parameterType="Map" resultType="Map">
+        select  count(1) count
+        FROM building_owner t , s_community_member cm
+        WHERE t.`member_id` = cm.`member_id`
+        AND cm.`community_id` = #{communityId}
+        AND cm.`status_cd` = '0'
+        AND t.`status_cd` = '0'
+        <if test="sex !=null and sex != ''">
+            and t.sex= #{sex}
+        </if>
+        <if test="name !=null and name != ''">
+            and t.name= #{name}
+        </if>
+        <if test="link !=null and link != ''">
+            and t.link= #{link}
+        </if>
+        <if test="statusCd !=null and statusCd != ''">
+            and t.status_cd= #{statusCd}
+        </if>
+        <if test="remark !=null and remark != ''">
+            and t.remark= #{remark}
+        </if>
+        <if test="ownerId !=null and ownerId != ''">
+            and t.owner_id= #{ownerId}
+        </if>
+        <if test="bId !=null and bId != ''">
+            and t.b_id= #{bId}
+        </if>
+        <if test="userId !=null and userId != ''">
+            and t.user_id= #{userId}
+        </if>
+        <if test="age !=null and age != ''">
+            and t.age= #{age}
+        </if>
+        <if test="memberId !=null and memberId != ''">
+            and t.member_id= #{memberId}
+        </if>
+
+
+    </select>
+
+
+    <!-- 查询业主信息 add by wuxw 2018-07-03 -->
+    <select id="getOwnerInfoByCondition" parameterType="Map" resultType="Map">
+    select  t.sex,t.name,t.link,t.status_cd,t.status_cd statusCd,t.remark,t.owner_id,t.owner_id ownerId,t.b_id,t.b_id bId,t.user_id,t.user_id userId,t.age,t.member_id,t.member_id memberId
+        FROM building_owner t , s_community_member cm
+        WHERE t.`member_id` = cm.`member_id`
+        AND cm.`community_id` = #{communityId}
+        AND cm.`status_cd` = '0'
+        AND t.`status_cd` = '0'
+    <if test="sex !=null and sex != ''">
+        and t.sex= #{sex}
+    </if>
+    <if test="name !=null and name != ''">
+        and t.name= #{name}
+    </if>
+    <if test="link !=null and link != ''">
+        and t.link= #{link}
+    </if>
+    <if test="statusCd !=null and statusCd != ''">
+        and t.status_cd= #{statusCd}
+    </if>
+    <if test="remark !=null and remark != ''">
+        and t.remark= #{remark}
+    </if>
+    <if test="ownerId !=null and ownerId != ''">
+        and t.owner_id= #{ownerId}
+    </if>
+    <if test="bId !=null and bId != ''">
+        and t.b_id= #{bId}
+    </if>
+    <if test="userId !=null and userId != ''">
+        and t.user_id= #{userId}
+    </if>
+    <if test="age !=null and age != ''">
+        and t.age= #{age}
+    </if>
+    <if test="memberId !=null and memberId != ''">
+        and t.member_id= #{memberId}
+    </if>
+    <if test="ownerIds != null and ownerIds != ''">
+        and t.owner_id in
+        <foreach collection="ownerIds" item="item" open="(" close=")" separator=",">
+            #{item}
+        </foreach>
+    </if>
+    <if test="page != -1 and page != null ">
+        limit #{page}, #{row}
+    </if>
+    </select>
+
 </mapper>

+ 4 - 3
java110-db/src/main/resources/mapper/room/RoomServiceDaoImplMapper.xml

@@ -152,13 +152,14 @@ where 1 =1
 </if> 
 <if test="apartment !=null and apartment != ''">
    and t.apartment= #{apartment}
-</if> 
-<if test="page != -1 and page != null">
-   limit #{page},#{row}
 </if>
         <if test="state !=null and state != ''">
             and t.state= #{state}
         </if>
+<if test="page != -1 and page != null">
+   limit #{page},#{row}
+</if>
+
 
     </select>