wuxw
2025-02-28 c1413aeb9fe5d736af38e25285ac8d88074a89bf
开发完成运营房屋查询
6个文件已修改
1个文件已添加
380 ■■■■■ 已修改文件
java110-db/src/main/resources/mapper/community/RoomServiceDaoImplMapper.xml 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-db/src/main/resources/mapper/user/OwnerRoomRelV1ServiceDaoImplMapper.xml 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-community/src/main/java/com/java110/community/bmo/room/IQueryRoomStatisticsBMO.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-community/src/main/java/com/java110/community/bmo/room/impl/QueryRoomStatisticsBMOImpl.java 86 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-community/src/main/java/com/java110/community/cmd/room/QueryAdminRoomCmd.java 118 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-community/src/main/java/com/java110/community/cmd/room/QueryRoomsCmd.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-report/src/main/java/com/java110/report/cmd/community/QueryCommunityUnitTreeCmd.java 122 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-db/src/main/resources/mapper/community/RoomServiceDaoImplMapper.xml
@@ -6,11 +6,11 @@
    <!-- 保存小区房屋信息 add by wuxw 2018-07-03 -->
    <insert id="saveBusinessRoomInfo" parameterType="Map">
        insert into business_building_room(fee_coefficient, section, remark, user_id, room_id, layer, built_up_area,
                                           operate, room_num, unit_id, b_id, apartment, state, community_id,
                                           room_type, room_sub_type, room_rent, room_area)
        operate, room_num, unit_id, b_id, apartment, state, community_id,
        room_type, room_sub_type, room_rent, room_area)
        values (#{feeCoefficient}, #{section}, #{remark}, #{userId}, #{roomId}, #{layer}, #{builtUpArea}, #{operate},
                #{roomNum}, #{unitId}, #{bId}, #{apartment}, #{state},
                #{communityId}, #{roomType}, #{roomSubType}, #{roomRent}, #{roomArea})
        #{roomNum}, #{unitId}, #{bId}, #{apartment}, #{state},
        #{communityId}, #{roomType}, #{roomSubType}, #{roomRent}, #{roomArea})
    </insert>
    <!-- 查询小区房屋信息(Business) add by wuxw 2018-07-03 -->
@@ -321,7 +321,9 @@
        '0'
        left join t_dict td on t.state = td.status_cd and td.table_name = 'building_room' and td.table_columns = 'state'
        WHERE 1 =1
        AND t.`community_id` = #{communityId}
        <if test="communityId !=null and communityId != ''">
            AND t.`community_id` = #{communityId}
        </if>
        and t.status_cd ='0'
        <if test="floorId !=null and floorId != ''">
            and f.`floor_id`= #{floorId}
@@ -340,6 +342,12 @@
        </if>
        <if test="roomId !=null and roomId != ''">
            and t.room_id= #{roomId}
        </if>
        <if test="roomIds != null">
            and t.room_id in
            <foreach collection="roomIds" item="item" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
        <if test="layer !=null and layer != ''">
            and t.layer= #{layer}
@@ -703,7 +711,7 @@
        left join t_dict td1 on t.room_sub_type = td1.status_cd and td1.table_name = 'building_room' and
        td1.table_columns = 'room_sub_type'
        WHERE 1 =1
        <if test="floorId !=null and floorId != ''">
        <if test="communityId !=null and communityId != ''">
            AND t.`community_id` = #{communityId}
        </if>
        <if test="floorId !=null and floorId != ''">
@@ -784,17 +792,14 @@
                #{item}
            </foreach>
        </if>
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        order by f.seq,u.unit_num,CONVERT(t.layer,SIGNED),CONVERT(t.room_num,SIGNED) asc
        <!-- order by t.create_time desc-->
        <if test="page != -1 and page != null">
            limit #{page},#{row}
        </if>
       order by f.seq,u.unit_num,CONVERT(t.layer,SIGNED),CONVERT(t.room_num,SIGNED) asc
    <!-- order by t.create_time desc-->
    <if test="page != -1 and page != null">
        limit #{page},#{row}
    </if>
</select>
    </select>
<!-- 根据业主查询房屋信息 -->
    <!-- 根据业主查询房屋信息 -->
    <select id="getRoomInfoByOwner" parameterType="Map" resultType="Map">
        SELECT
        t.fee_coefficient,t.fee_coefficient feeCoefficient,t.section,t.status_cd,t.status_cd
java110-db/src/main/resources/mapper/user/OwnerRoomRelV1ServiceDaoImplMapper.xml
@@ -19,8 +19,12 @@
        inner join building_room br on t.room_id = br.room_id and br.status_cd = '0'
        inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
        inner join f_floor fl on bu.floor_id = fl.floor_id and fl.status_cd = '0'
        where 1 =1
        <if test="ownerNameLike !=null and ownerNameLike != ''">
            and bo.`name` like concat('%',#{ownerNameLike},'%')
        </if>
        <if test="link !=null and link != ''">
            and bo.`link` = #{link}
        </if>
        <if test="relId !=null and relId != ''">
            and t.rel_id= #{relId}
@@ -103,6 +107,12 @@
        inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
        inner join f_floor fl on bu.floor_id = fl.floor_id and fl.status_cd = '0'
        where 1 =1
        <if test="ownerNameLike !=null and ownerNameLike != ''">
            and bo.`name` like concat('%',#{ownerNameLike},'%')
        </if>
        <if test="link !=null and link != ''">
            and bo.`link` = #{link}
        </if>
        <if test="relId !=null and relId != ''">
            and t.rel_id= #{relId}
        </if>
service-community/src/main/java/com/java110/community/bmo/room/IQueryRoomStatisticsBMO.java
@@ -22,4 +22,6 @@
     * @return
     */
    List<RoomDto> queryRoomOweFee(List<RoomDto> roomDtos);
    List<RoomDto> querySimple(List<RoomDto> roomDtos);
}
service-community/src/main/java/com/java110/community/bmo/room/impl/QueryRoomStatisticsBMOImpl.java
@@ -1,6 +1,7 @@
package com.java110.community.bmo.room.impl;
import com.java110.community.bmo.room.IQueryRoomStatisticsBMO;
import com.java110.dto.owner.OwnerRoomRelDto;
import com.java110.dto.room.RoomDto;
import com.java110.intf.store.IComplaintV1InnerServiceSMO;
import com.java110.intf.community.IRepairPoolV1InnerServiceSMO;
@@ -22,7 +23,7 @@
@Service
public class QueryRoomStatisticsBMOImpl implements IQueryRoomStatisticsBMO {
    public static final int MAX_LINE_COUNT = 15;
    public static final int MAX_LINE_COUNT = 30;
    @Autowired
    private IOwnerRoomRelV1InnerServiceSMO ownerRoomRelV1InnerServiceSMOImpl;
@@ -48,7 +49,7 @@
    @Override
    public List<RoomDto> query(List<RoomDto> roomDtos) {
        if (roomDtos == null || roomDtos.size() < 1) {
        if (ListUtil.isNull(roomDtos)) {
            return roomDtos;
        }
@@ -59,6 +60,8 @@
        List<String> roomIds = new ArrayList<>();
        List<String> ownerIds = new ArrayList<>();
        List<String> ownerTels = new ArrayList<>();
        for (RoomDto roomDto : roomDtos) {
            if (!StringUtil.isEmpty(roomDto.getOwnerId())) {
                ownerIds.add(roomDto.getOwnerId());
@@ -69,6 +72,7 @@
            roomIds.add(roomDto.getRoomId());
        }
        // 查询 家庭成员数
        queryOwnerMemberCount(ownerIds, roomDtos);
@@ -97,6 +101,77 @@
        return roomDtos;
    }
    @Override
    public List<RoomDto> querySimple(List<RoomDto> roomDtos) {
        if (ListUtil.isNull(roomDtos)) {
            return roomDtos;
        }
        //这里限制行数,以免影响系统性能
        if (roomDtos.size() > MAX_LINE_COUNT) {
            return roomDtos;
        }
        List<String> roomIds = new ArrayList<>();
        for (RoomDto roomDto : roomDtos) {
            roomIds.add(roomDto.getRoomId());
        }
        // 查询业主信息
        queryRoomOwner(roomIds, roomDtos);
        List<String> ownerIds = new ArrayList<>();
        List<String> ownerTels = new ArrayList<>();
        for (RoomDto roomDto : roomDtos) {
            if (!StringUtil.isEmpty(roomDto.getOwnerId())) {
                ownerIds.add(roomDto.getOwnerId());
            }
            if (!StringUtil.isEmpty(roomDto.getOwnerTel())) {
                ownerTels.add(roomDto.getOwnerTel());
            }
        }
        // 查询 家庭成员数
        queryOwnerMemberCount(ownerIds, roomDtos);
        // 查询 车辆数
        queryCarCount(ownerIds, roomDtos);
        // 查询 房屋数量
        queryRoomCount(ownerIds, roomDtos);
        // 查询房屋 合同
        queryRoomContract(roomIds, roomDtos);
        return roomDtos;
    }
    private void queryRoomOwner(List<String> roomIds, List<RoomDto> roomDtos) {
        if (ListUtil.isNull(roomDtos)) {
            return;
        }
        OwnerRoomRelDto ownerRoomRelDto = new OwnerRoomRelDto();
        ownerRoomRelDto.setRoomIds(roomIds.toArray(new String[roomIds.size()]));
        List<OwnerRoomRelDto> ownerRoomRelDtos = ownerRoomRelV1InnerServiceSMOImpl.queryOwnerRoomRels(ownerRoomRelDto);
        if (ListUtil.isNull(ownerRoomRelDtos)) {
            return;
        }
        for (RoomDto tmpRoomDto : roomDtos) {
            for (OwnerRoomRelDto tOwnerRoomRelDto : ownerRoomRelDtos) {
                if (!tmpRoomDto.getRoomId().equals(tOwnerRoomRelDto.getRoomId())) {
                    continue;
                }
                tmpRoomDto.setOwnerId(tOwnerRoomRelDto.getOwnerId());
                tmpRoomDto.setOwnerName(tOwnerRoomRelDto.getOwnerName());
                tmpRoomDto.setOwnerTel(tOwnerRoomRelDto.getLink());
                tmpRoomDto.setStartTime(tOwnerRoomRelDto.getStartTime());
                tmpRoomDto.setEndTime(tOwnerRoomRelDto.getEndTime());
                tmpRoomDto.setLink(tOwnerRoomRelDto.getLink());
            }
        }
    }
    @Override
    public List<RoomDto> queryRoomOweFee(List<RoomDto> roomDtos) {
        if (ListUtil.isNull(roomDtos)) {
@@ -111,6 +186,7 @@
        return roomDtos;
    }
    /**
     * 查询
     *
@@ -118,7 +194,7 @@
     * @param roomDtos
     */
    private void queryRoomContract(List<String> roomIds, List<RoomDto> roomDtos) {
        if (roomDtos == null || roomDtos.size() < 1) {
        if (ListUtil.isNull(roomDtos)) {
            return;
        }
        Map info = new HashMap();
@@ -231,7 +307,7 @@
     * @param roomDtos
     */
    private void queryComplaintCount(List<String> ownerTels, List<RoomDto> roomDtos) {
        if (ownerTels == null || ownerTels.size() < 1) {
        if (ListUtil.isNull(ownerTels)) {
            return;
        }
@@ -289,7 +365,7 @@
     * @param roomDtos
     */
    private void queryOwnerMemberCount(List<String> ownerIds, List<RoomDto> roomDtos) {
        if (ownerIds == null || ownerIds.size() < 1) {
        if (ListUtil.isNull(ownerIds)) {
            return;
        }
service-community/src/main/java/com/java110/community/cmd/room/QueryAdminRoomCmd.java
New file
@@ -0,0 +1,118 @@
package com.java110.community.cmd.room;
import com.alibaba.fastjson.JSONObject;
import com.java110.community.bmo.room.IQueryRoomStatisticsBMO;
import com.java110.core.annotation.Java110Cmd;
import com.java110.core.context.ICmdDataFlowContext;
import com.java110.core.event.cmd.Cmd;
import com.java110.core.event.cmd.CmdEvent;
import com.java110.dto.owner.OwnerRoomRelDto;
import com.java110.dto.room.RoomDto;
import com.java110.intf.community.IRoomInnerServiceSMO;
import com.java110.intf.user.IOwnerRoomRelV1InnerServiceSMO;
import com.java110.utils.exception.CmdException;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.utils.util.ListUtil;
import com.java110.utils.util.StringUtil;
import com.java110.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
@Java110Cmd(serviceCode = "room.queryAdminRoom")
public class QueryAdminRoomCmd extends Cmd {
    @Autowired
    private IRoomInnerServiceSMO roomInnerServiceSMOImpl;
    @Autowired
    private IQueryRoomStatisticsBMO queryRoomStatisticsBMOImpl;
    @Autowired
    private IOwnerRoomRelV1InnerServiceSMO ownerRoomRelV1InnerServiceSMOImpl;
    @Override
    public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
        super.validateAdmin(context);
        super.validatePageInfo(reqJson);
    }
    @Override
    public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
        RoomDto roomDto = BeanConvertUtil.covertBean(reqJson, RoomDto.class);
        // 计算根据业主查询
        computeOwnerRoomIds(reqJson, roomDto);
        //todo 计算楼栋单元房屋编号
        computeFloorUnitRoomNum(reqJson, roomDto);
        int count = roomInnerServiceSMOImpl.queryRoomsCount(roomDto);
        List<RoomDto> roomDtos = null;
        if (count > 0) {
            roomDtos = roomInnerServiceSMOImpl.queryRooms(roomDto);
            // todo 查询房屋统计数据
            roomDtos = queryRoomStatisticsBMOImpl.querySimple(roomDtos);
        } else {
            roomDtos = new ArrayList<>();
        }
        ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) reqJson.getInteger("row")), count, roomDtos);
        ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
        context.setResponseEntity(responseEntity);
    }
    private void computeOwnerRoomIds(JSONObject reqJson, RoomDto roomDto) {
        String ownerNameLike = reqJson.getString("ownerNameLike");
        String ownerTel = reqJson.getString("ownerTel");
        if (StringUtil.isEmpty(ownerNameLike) && StringUtil.isEmpty(ownerTel)) {
            return;
        }
        OwnerRoomRelDto ownerRoomRelDto = new OwnerRoomRelDto();
        ownerRoomRelDto.setOwnerNameLike(reqJson.getString("ownerNameLike"));
        ownerRoomRelDto.setLink(ownerTel);
        List<OwnerRoomRelDto> ownerRoomRelDtos = ownerRoomRelV1InnerServiceSMOImpl.queryOwnerRoomRels(ownerRoomRelDto);
        if (ListUtil.isNull(ownerRoomRelDtos)) { // 表示后续查不到
            roomDto.setRoomId("-1");
            return;
        }
        List<String> roomIds = new ArrayList<>();
        for (OwnerRoomRelDto tOwnerRoomRelDto : ownerRoomRelDtos) {
            roomIds.add(tOwnerRoomRelDto.getRoomId());
        }
        roomDto.setRoomIds(roomIds.toArray(new String[roomIds.size()]));
    }
    /**
     * 计算 楼栋单元房屋编号
     *
     * @param reqJson
     * @param roomDto
     */
    private static void computeFloorUnitRoomNum(JSONObject reqJson, RoomDto roomDto) {
        if (!reqJson.containsKey("roomNum") || StringUtil.isEmpty(reqJson.getString("roomNum"))) {
            roomDto.setUnitNum("");
            roomDto.setFloorNum("");
            roomDto.setRoomNum("");
            return;
        }
        String[] roomNums = reqJson.getString("roomNum").split("-", 3);
        if (roomNums.length == 3) {
            roomDto.setFloorNum(roomNums[0]);
            roomDto.setUnitNum(roomNums[1]);
            roomDto.setRoomNum(roomNums[2]);
            return;
        }
        roomDto.setRoomNum(reqJson.getString("roomNum"));
    }
}
service-community/src/main/java/com/java110/community/cmd/room/QueryRoomsCmd.java
@@ -19,10 +19,7 @@
import com.java110.utils.constant.ResponseConstant;
import com.java110.utils.exception.CmdException;
import com.java110.utils.exception.SMOException;
import com.java110.utils.util.Assert;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.utils.util.DateUtil;
import com.java110.utils.util.StringUtil;
import com.java110.utils.util.*;
import com.java110.vo.api.ApiRoomDataVo;
import com.java110.vo.api.ApiRoomVo;
import org.springframework.beans.factory.annotation.Autowired;
@@ -259,7 +256,7 @@
        floorDto.setFloorNum(reqJson.getString("floorNum"));
        floorDto.setCommunityId(reqJson.getString("communityId"));
        List<FloorDto> floorDtos = floorInnerServiceSMOImpl.queryFloors(floorDto);
        if (floorDtos == null || floorDtos.isEmpty()) {
        if (ListUtil.isNull(floorDtos)) {
            return;
        }
service-report/src/main/java/com/java110/report/cmd/community/QueryCommunityUnitTreeCmd.java
@@ -11,6 +11,7 @@
import com.java110.intf.report.IReportCommunityInnerServiceSMO;
import com.java110.utils.exception.CmdException;
import com.java110.utils.util.ListUtil;
import com.java110.utils.util.StringUtil;
import com.java110.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
@@ -48,22 +49,125 @@
        }
        JSONObject communityInfo = null;
        for(UnitDto tmpUnitDto:unitDtos){
            if(!hasInCommunitys(tmpUnitDto,communitys)){
        for (UnitDto tmpUnitDto : unitDtos) {
            if (!hasInCommunity(tmpUnitDto, communitys)) {
                communityInfo = new JSONObject();
                communityInfo.put("id","c_"+tmpUnitDto.getCommunityId());
                communityInfo.put("communityId",tmpUnitDto.getCommunityId());
                communityInfo.put("text",tmpUnitDto.getCommunityName());
                communityInfo.put("icon","/img/org.png");
                communityInfo.put("children",new JSONArray());
                communityInfo.put("id", "c_" + tmpUnitDto.getCommunityId());
                communityInfo.put("communityId", tmpUnitDto.getCommunityId());
                communityInfo.put("text", tmpUnitDto.getCommunityName());
                communityInfo.put("icon", "/img/org.png");
                communityInfo.put("children", new JSONArray());
                communitys.add(communityInfo);
            }
        }
        JSONObject community = null;
        for (int cIndex = 0; cIndex < communitys.size(); cIndex++) {
            community = communitys.getJSONObject(cIndex);
            // find floor data in unitDtos
            findFloor(community, unitDtos);
        }
        context.setResponseEntity(ResultVo.createResponseEntity(communitys));
    }
    /**
     * find community floor data
     *
     * @param community current community
     * @param unitDtos  all units data
     */
    private void findFloor(JSONObject community, List<UnitDto> unitDtos) {
        JSONArray floors = community.getJSONArray("children");
        JSONObject floorInfo = null;
        for (UnitDto tmpUnitDto : unitDtos) {
            if (!hasInFloor(tmpUnitDto, floors)) {
                floorInfo = new JSONObject();
                floorInfo.put("id", "f_" + tmpUnitDto.getFloorId());
                floorInfo.put("floorId", tmpUnitDto.getFloorId());
                floorInfo.put("text", tmpUnitDto.getFloorNum()+"栋");
                floorInfo.put("icon", "/img/floor.png");
                floorInfo.put("children", new JSONArray());
                floors.add(floorInfo);
            }
        }
        JSONObject floor = null;
        for (int cIndex = 0; cIndex < floors.size(); cIndex++) {
            floor = floors.getJSONObject(cIndex);
            // find floor data in unitDtos
            findUnit(floor, unitDtos);
        }
    }
    private void findUnit(JSONObject floor, List<UnitDto> unitDtos) {
        JSONArray units = floor.getJSONArray("children");
        JSONObject unitInfo = null;
        for (UnitDto tmpUnitDto : unitDtos) {
            if (!hasInUnit(tmpUnitDto, units)) {
                unitInfo = new JSONObject();
                unitInfo.put("id", "u_" + tmpUnitDto.getUnitId());
                unitInfo.put("unitId", tmpUnitDto.getUnitId());
                unitInfo.put("text", tmpUnitDto.getUnitNum()+"单元");
                unitInfo.put("icon", "/img/unit.png");
                units.add(unitInfo);
            }
        }
    }
    private boolean hasInCommunitys(UnitDto tmpUnitDto,JSONArray communitys) {
        return true;
    private boolean hasInUnit(UnitDto unitDto, JSONArray units) {
        JSONObject unit = null;
        for (int cIndex = 0; cIndex < units.size(); cIndex++) {
            unit = units.getJSONObject(cIndex);
            if (!unit.containsKey("unitId")) {
                continue;
            }
            if (StringUtil.isEmpty(unit.getString("unitId"))) {
                continue;
            }
            if (unit.getString("unitId").equals(unitDto.getUnitId())) {
                return true;
            }
        }
        return false;
    }
    private boolean hasInFloor(UnitDto tmpUnitDto, JSONArray floors) {
        JSONObject floor = null;
        for (int cIndex = 0; cIndex < floors.size(); cIndex++) {
            floor = floors.getJSONObject(cIndex);
            if (!floor.containsKey("floorId")) {
                continue;
            }
            if (StringUtil.isEmpty(floor.getString("floorId"))) {
                continue;
            }
            if (floor.getString("floorId").equals(tmpUnitDto.getFloorId())) {
                return true;
            }
        }
        return false;
    }
    private boolean hasInCommunity(UnitDto tmpUnitDto, JSONArray communitys) {
        JSONObject community = null;
        for (int cIndex = 0; cIndex < communitys.size(); cIndex++) {
            community = communitys.getJSONObject(cIndex);
            if (!community.containsKey("communityId")) {
                continue;
            }
            if (StringUtil.isEmpty(community.getString("communityId"))) {
                continue;
            }
            if (community.getString("communityId").equals(tmpUnitDto.getCommunityId())) {
                return true;
            }
        }
        return false;
    }