| | |
| | | package com.java110.community.bmo.room.impl; |
| | | |
| | | import com.java110.community.bmo.room.IQueryRoomStatisticsBMO; |
| | | import com.java110.dto.RoomDto; |
| | | import com.java110.dto.owner.OwnerDto; |
| | | import com.java110.intf.community.IComplaintV1InnerServiceSMO; |
| | | import com.java110.dto.owner.OwnerRoomRelDto; |
| | | import com.java110.dto.room.RoomDto; |
| | | import com.java110.intf.store.IComplaintV1InnerServiceSMO; |
| | | import com.java110.intf.community.IRepairPoolV1InnerServiceSMO; |
| | | import com.java110.intf.report.IReportOweFeeInnerServiceSMO; |
| | | import com.java110.intf.store.IContractRoomInnerServiceSMO; |
| | | import com.java110.intf.user.IOwnerCarV1InnerServiceSMO; |
| | | import com.java110.intf.user.IOwnerRoomRelV1InnerServiceSMO; |
| | | import com.java110.intf.user.IOwnerV1InnerServiceSMO; |
| | | import com.java110.utils.util.ListUtil; |
| | | import com.java110.utils.util.StringUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | @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; |
| | |
| | | @Override |
| | | public List<RoomDto> query(List<RoomDto> roomDtos) { |
| | | |
| | | if (roomDtos == null || roomDtos.size() < 1) { |
| | | if (ListUtil.isNull(roomDtos)) { |
| | | return roomDtos; |
| | | } |
| | | |
| | |
| | | List<String> roomIds = new ArrayList<>(); |
| | | List<String> ownerIds = new ArrayList<>(); |
| | | List<String> ownerTels = new ArrayList<>(); |
| | | |
| | | |
| | | for (RoomDto roomDto : roomDtos) { |
| | | ownerIds.add(roomDto.getOwnerId()); |
| | | ownerTels.add(roomDto.getOwnerTel()); |
| | | if (!StringUtil.isEmpty(roomDto.getOwnerId())) { |
| | | ownerIds.add(roomDto.getOwnerId()); |
| | | } |
| | | if (!StringUtil.isEmpty(roomDto.getOwnerTel())) { |
| | | ownerTels.add(roomDto.getOwnerTel()); |
| | | } |
| | | |
| | | roomIds.add(roomDto.getRoomId()); |
| | | } |
| | | |
| | | |
| | | // 查询 家庭成员数 |
| | | queryOwnerMemberCount(ownerIds, roomDtos); |
| | |
| | | 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 (roomDtos == null || roomDtos.size() < 1) { |
| | | if (ListUtil.isNull(roomDtos)) { |
| | | return roomDtos; |
| | | } |
| | | List<String> roomIds = new ArrayList<>(); |
| | |
| | | return roomDtos; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询 |
| | | * |
| | |
| | | * @param roomDtos |
| | | */ |
| | | private void queryRoomContract(List<String> roomIds, List<RoomDto> roomDtos) { |
| | | if (ListUtil.isNull(roomDtos)) { |
| | | return; |
| | | } |
| | | Map info = new HashMap(); |
| | | info.put("communityId", roomDtos.get(0).getCommunityId()); |
| | | info.put("roomIds", roomIds.toArray(new String[roomIds.size()])); |
| | |
| | | |
| | | for (RoomDto roomDto : roomDtos) { |
| | | for (Map count : repairCounts) { |
| | | if (roomDto.getRoomId().equals(count.get("roomId"))) { |
| | | roomDto.setContractCount(count.get("contractCount").toString()); |
| | | if (!StringUtil.isEmpty(roomDto.getRoomId()) && !StringUtil.isEmpty(count.get("roomId").toString())) { |
| | | if (roomDto.getRoomId().equals(count.get("roomId").toString())) { |
| | | roomDto.setContractCount(count.get("contractCount").toString()); |
| | | } |
| | | } else { |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void queryRoomOweFee(List<String> roomIds, List<RoomDto> roomDtos) { |
| | | if (ListUtil.isNull(roomIds)) { |
| | | return; |
| | | } |
| | | Map info = new HashMap(); |
| | | info.put("communityId", roomDtos.get(0).getCommunityId()); |
| | | info.put("roomIds", roomIds.toArray(new String[roomIds.size()])); |
| | |
| | | |
| | | for (RoomDto roomDto : roomDtos) { |
| | | for (Map count : repairCounts) { |
| | | if (roomDto.getRoomId().equals(count.get("roomId"))) { |
| | | if (StringUtil.isEmpty(roomDto.getRoomId())) { |
| | | continue; |
| | | } |
| | | if (StringUtil.isEmpty(count.get("roomId").toString())) { |
| | | continue; |
| | | } |
| | | if (roomDto.getRoomId().equals(count.get("roomId").toString())) { |
| | | roomDto.setRoomOweFee(count.get("oweFee").toString()); |
| | | } |
| | | } |
| | |
| | | * @param roomDtos |
| | | */ |
| | | private void queryOwnerOweFee(List<String> ownerIds, List<RoomDto> roomDtos) { |
| | | if (ownerIds == null || ownerIds.size() < 1) { |
| | | return; |
| | | } |
| | | Map info = new HashMap(); |
| | | info.put("communityId", roomDtos.get(0).getCommunityId()); |
| | | info.put("ownerIds", ownerIds.toArray(new String[ownerIds.size()])); |
| | | List<Map> repairCounts = reportOweFeeInnerServiceSMOImpl.queryOweFeesByOwnerIds(info); |
| | | |
| | | for (RoomDto roomDto : roomDtos) { |
| | | if (StringUtil.isEmpty(roomDto.getOwnerId())) { |
| | | continue; |
| | | } |
| | | for (Map count : repairCounts) { |
| | | if (roomDto.getOwnerId().equals(count.get("ownerId"))) { |
| | | roomDto.setOweFee(count.get("oweFee").toString()); |
| | | if (!StringUtil.isEmpty(roomDto.getOwnerId()) && !StringUtil.isEmpty(count.get("ownerId").toString())) { |
| | | if (roomDto.getOwnerId().equals(count.get("ownerId").toString())) { |
| | | roomDto.setOweFee(count.get("oweFee").toString()); |
| | | } |
| | | } else { |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | private void queryRepairCount(List<String> ownerTels, List<RoomDto> roomDtos) { |
| | | |
| | | |
| | | if (ownerTels == null || ownerTels.size() < 1) { |
| | | return; |
| | | } |
| | | Map info = new HashMap(); |
| | | info.put("communityId", roomDtos.get(0).getCommunityId()); |
| | | info.put("ownerTels", ownerTels.toArray(new String[ownerTels.size()])); |
| | |
| | | |
| | | for (RoomDto roomDto : roomDtos) { |
| | | for (Map count : repairCounts) { |
| | | if (roomDto.getLink().equals(count.get("ownerTel"))) { |
| | | roomDto.setRepairCount(count.get("repairCount").toString()); |
| | | if (!StringUtil.isEmpty(roomDto.getLink()) && !StringUtil.isEmpty(count.get("ownerTel").toString())) { |
| | | if (roomDto.getLink().equals(count.get("ownerTel").toString())) { |
| | | roomDto.setRepairCount(count.get("repairCount").toString()); |
| | | } |
| | | } else { |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | |
| | | * @param roomDtos |
| | | */ |
| | | private void queryComplaintCount(List<String> ownerTels, List<RoomDto> roomDtos) { |
| | | |
| | | if (ListUtil.isNull(ownerTels)) { |
| | | return; |
| | | } |
| | | |
| | | Map info = new HashMap(); |
| | | info.put("communityId", roomDtos.get(0).getCommunityId()); |
| | |
| | | |
| | | for (RoomDto roomDto : roomDtos) { |
| | | for (Map count : complaintCounts) { |
| | | if (roomDto.getLink().equals(count.get("ownerTel"))) { |
| | | roomDto.setComplaintCount(count.get("complaintCount").toString()); |
| | | if (!StringUtil.isEmpty(roomDto.getLink()) && !StringUtil.isEmpty(count.get("ownerTel").toString())) { |
| | | if (roomDto.getLink().equals(count.get("ownerTel").toString())) { |
| | | roomDto.setComplaintCount(count.get("complaintCount").toString()); |
| | | } |
| | | } else { |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | |
| | | * @param roomDtos |
| | | */ |
| | | private void queryCarCount(List<String> ownerIds, List<RoomDto> roomDtos) { |
| | | if (ownerIds == null || ownerIds.size() < 1) { |
| | | return; |
| | | } |
| | | |
| | | List<Map> memberCounts = ownerCarV1InnerServiceSMOImpl.queryOwnerCarCountByOwnerIds(ownerIds); |
| | | |
| | | for (RoomDto roomDto : roomDtos) { |
| | | if (StringUtil.isEmpty(roomDto.getOwnerId())) { |
| | | continue; |
| | | } |
| | | for (Map count : memberCounts) { |
| | | if (roomDto.getOwnerId().equals(count.get("ownerId"))) { |
| | | roomDto.setCarCount(count.get("carCount").toString()); |
| | | if (!StringUtil.isEmpty(roomDto.getOwnerId()) && !StringUtil.isEmpty(count.get("ownerId").toString())) { |
| | | if (roomDto.getOwnerId().equals(count.get("ownerId").toString())) { |
| | | roomDto.setCarCount(count.get("carCount").toString()); |
| | | } |
| | | } else { |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | |
| | | * @param roomDtos |
| | | */ |
| | | private void queryOwnerMemberCount(List<String> ownerIds, List<RoomDto> roomDtos) { |
| | | if (ListUtil.isNull(ownerIds)) { |
| | | return; |
| | | } |
| | | |
| | | List<Map> memberCounts = ownerV1InnerServiceSMOImpl.queryOwnerMembersCount(ownerIds); |
| | | |
| | | for (RoomDto roomDto : roomDtos) { |
| | | if (StringUtil.isEmpty(roomDto.getOwnerId())) { |
| | | continue; |
| | | } |
| | | for (Map count : memberCounts) { |
| | | if (roomDto.getOwnerId().equals(count.get("ownerId"))) { |
| | | roomDto.setMemberCount(count.get("memberCount").toString()); |
| | |
| | | */ |
| | | private void queryRoomCount(List<String> ownerIds, List<RoomDto> roomDtos) { |
| | | |
| | | if (ownerIds == null || ownerIds.size() < 1) { |
| | | return; |
| | | } |
| | | |
| | | //查询业主房屋数 |
| | | List<Map> ownerRoomCounts = ownerRoomRelV1InnerServiceSMOImpl.queryRoomCountByOwnerIds(ownerIds); |
| | | |
| | | for (RoomDto roomDto : roomDtos) { |
| | | for (Map count : ownerRoomCounts) { |
| | | if(StringUtil.isEmpty(roomDto.getOwnerId())){ |
| | | if (StringUtil.isEmpty(roomDto.getOwnerId()) || StringUtil.isEmpty(count.get("ownerId").toString())) { |
| | | continue; |
| | | } |
| | | if (roomDto.getOwnerId().equals(count.get("ownerId"))) { |
| | | if (roomDto.getOwnerId().equals(count.get("ownerId").toString())) { |
| | | roomDto.setRoomCount(count.get("roomCount").toString()); |
| | | } |
| | | } |