| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.core.annotation.Java110Cmd; |
| | | import com.java110.core.context.ICmdDataFlowContext; |
| | | import com.java110.core.event.cmd.AbstractServiceCmdListener; |
| | | import com.java110.core.event.cmd.Cmd; |
| | | import com.java110.core.event.cmd.CmdEvent; |
| | | import com.java110.dto.FloorDto; |
| | | import com.java110.dto.RoomDto; |
| | | import com.java110.dto.UnitDto; |
| | | import com.java110.dto.basePrivilege.BasePrivilegeDto; |
| | | import com.java110.dto.owner.OwnerDto; |
| | | import com.java110.dto.owner.OwnerRoomRelDto; |
| | | import com.java110.intf.community.IFloorInnerServiceSMO; |
| | | import com.java110.intf.community.IMenuInnerServiceSMO; |
| | | import com.java110.intf.community.IRoomInnerServiceSMO; |
| | |
| | | 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.vo.api.ApiRoomDataVo; |
| | | import com.java110.vo.api.ApiRoomVo; |
| | | import org.apache.kafka.common.protocol.types.Field; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.ResponseEntity; |
| | |
| | | import java.util.Map; |
| | | |
| | | @Java110Cmd(serviceCode = "room.queryRooms") |
| | | public class QueryRoomsCmd extends AbstractServiceCmdListener { |
| | | public class QueryRoomsCmd extends Cmd { |
| | | |
| | | @Autowired |
| | | private IUnitInnerServiceSMO unitInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IFloorInnerServiceSMO floorInnerServiceSMOImpl; |
| | | |
| | | |
| | | @Autowired |
| | | private IRoomInnerServiceSMO roomInnerServiceSMOImpl; |
| | |
| | | public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException { |
| | | RoomDto roomDto = BeanConvertUtil.covertBean(reqJson, RoomDto.class); |
| | | |
| | | //导致业务受理搜索查询 |
| | | // if (reqJson.containsKey("flag") && reqJson.getString("flag").equals("1")) { |
| | | // if (reqJson.containsKey("roomNumLike") && !StringUtil.isEmpty(reqJson.getString("roomNumLike"))) { |
| | | // String[] roomNumLikes = reqJson.getString("roomNumLike").split("-"); |
| | | // roomDto.setFloorNum(roomNumLikes[0]); |
| | | // roomDto.setUnitNum(roomNumLikes[1]); |
| | | // roomDto.setRoomNum(roomNumLikes[2]); |
| | | // roomDto.setRoomNumLike(""); |
| | | // } |
| | | // } |
| | | String roomId = ""; |
| | | String unitId = ""; |
| | | if (reqJson.containsKey("flag") && !StringUtil.isEmpty(reqJson.getString("flag")) && reqJson.getString("flag").equals("0") |
| | | && reqJson.containsKey("floorNum") && !StringUtil.isEmpty(reqJson.getString("floorNum")) |
| | | && reqJson.containsKey("unitNum") && !StringUtil.isEmpty(reqJson.getString("unitNum")) |
| | | && reqJson.containsKey("roomNum") && !StringUtil.isEmpty(reqJson.getString("roomNum"))) { |
| | | FloorDto floorDto = new FloorDto(); |
| | | floorDto.setFloorNum(reqJson.getString("floorNum")); |
| | | floorDto.setCommunityId(reqJson.getString("communityId")); |
| | | List<FloorDto> floorDtos = floorInnerServiceSMOImpl.queryFloors(floorDto); |
| | | if (floorDtos != null && floorDtos.size() > 0) { |
| | | for (FloorDto floor : floorDtos) { |
| | | UnitDto unitDto = new UnitDto(); |
| | | unitDto.setFloorId(floor.getFloorId()); |
| | | unitDto.setUnitNum(reqJson.getString("unitNum")); |
| | | List<UnitDto> unitDtos = unitInnerServiceSMOImpl.queryUnits(unitDto); |
| | | if (unitDtos != null && unitDtos.size() > 0) { |
| | | for (UnitDto unit : unitDtos) { |
| | | RoomDto room = new RoomDto(); |
| | | room.setUnitId(unit.getUnitId()); |
| | | room.setRoomNum(reqJson.getString("roomNum")); |
| | | room.setCommunityId(reqJson.getString("communityId")); |
| | | List<RoomDto> roomDtos = roomInnerServiceSMOImpl.queryRooms(room); |
| | | if (roomDtos != null && roomDtos.size() == 1) { |
| | | unitId = roomDtos.get(0).getUnitId(); |
| | | roomId = roomDtos.get(0).getRoomId(); |
| | | } else { |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | roomDto.setRoomId(roomId); |
| | | roomDto.setUnitId(unitId); |
| | | } |
| | | if (reqJson.containsKey("flag") && !StringUtil.isEmpty(reqJson.getString("flag")) && reqJson.getString("flag").equals("1")) { |
| | | if (reqJson.containsKey("roomNum") && !StringUtil.isEmpty(reqJson.getString("roomNum"))) { |
| | | String[] roomNums = reqJson.getString("roomNum").split("-"); |
| | | if (roomNums != null && roomNums.length == 3) { |
| | | roomDto.setFloorNum(roomNums[0]); |
| | | roomDto.setUnitNum(roomNums[1]); |
| | | roomDto.setRoomNum(roomNums[2]); |
| | | } else { |
| | | throw new IllegalArgumentException("房屋编号错误!"); |
| | | } |
| | | } else { |
| | | roomDto.setUnitNum(""); |
| | | roomDto.setFloorNum(""); |
| | | roomDto.setRoomNum(""); |
| | | } |
| | | } |
| | | ApiRoomVo apiRoomVo = new ApiRoomVo(); |
| | | //查询总记录数 |
| | | int total = roomInnerServiceSMOImpl.queryRoomsCount(BeanConvertUtil.covertBean(reqJson, RoomDto.class)); |
| | | int total = roomInnerServiceSMOImpl.queryRoomsCount(roomDto); |
| | | apiRoomVo.setTotal(total); |
| | | List<RoomDto> roomDtoList = null; |
| | | if (total > 0) { |
| | | roomDtoList = roomInnerServiceSMOImpl.queryRooms(roomDto); |
| | | refreshRoomOwners(reqJson.getString("userId"), reqJson.getString("communityId"), roomDtoList); |
| | | refreshRoomOwners(reqJson.getString("loginUserId"), reqJson.getString("communityId"), roomDtoList); |
| | | } else { |
| | | roomDtoList = new ArrayList<>(); |
| | | } |
| | |
| | | List<OwnerDto> ownerDtos = ownerInnerServiceSMOImpl.queryOwnersByRoom(ownerDto); |
| | | for (RoomDto roomDto : roomDtos) { |
| | | for (OwnerDto tmpOwnerDto : ownerDtos) { |
| | | if (roomDto.getRoomId().equals(tmpOwnerDto.getRoomId())) { |
| | | roomDto.setOwnerId(tmpOwnerDto.getOwnerId()); |
| | | roomDto.setOwnerName(tmpOwnerDto.getName()); |
| | | //对业主身份证号隐藏处理 |
| | | String idCard = tmpOwnerDto.getIdCard(); |
| | | if (mark.size() == 0 && idCard != null && !idCard.equals("") && idCard.length() > 15) { |
| | | idCard = idCard.substring(0, 6) + "**********" + idCard.substring(16); |
| | | } |
| | | //对业主手机号隐藏处理 |
| | | String link = tmpOwnerDto.getLink(); |
| | | if (mark.size() == 0 && link != null && !link.equals("") && link.length() > 10) { |
| | | link = link.substring(0, 3) + "****" + link.substring(7); |
| | | } |
| | | roomDto.setIdCard(idCard); |
| | | roomDto.setLink(link); |
| | | if (!roomDto.getRoomId().equals(tmpOwnerDto.getRoomId())) { |
| | | continue; |
| | | } |
| | | try { |
| | | roomDto.setStartTime(DateUtil.getDateFromString(tmpOwnerDto.getStartTime(), DateUtil.DATE_FORMATE_STRING_A)); |
| | | roomDto.setEndTime(DateUtil.getDateFromString(tmpOwnerDto.getEndTime(), DateUtil.DATE_FORMATE_STRING_A)); |
| | | } catch (Exception e) { |
| | | // |
| | | } |
| | | roomDto.setOwnerId(tmpOwnerDto.getOwnerId()); |
| | | roomDto.setOwnerName(tmpOwnerDto.getName()); |
| | | //对业主身份证号隐藏处理 |
| | | String idCard = tmpOwnerDto.getIdCard(); |
| | | if (mark.size() == 0 && idCard != null && !idCard.equals("") && idCard.length() > 15) { |
| | | idCard = idCard.substring(0, 6) + "**********" + idCard.substring(16); |
| | | } |
| | | //对业主手机号隐藏处理 |
| | | String link = tmpOwnerDto.getLink(); |
| | | if (mark.size() == 0 && link != null && !link.equals("") && link.length() > 10) { |
| | | link = link.substring(0, 3) + "****" + link.substring(7); |
| | | } |
| | | roomDto.setIdCard(idCard); |
| | | roomDto.setLink(link); |
| | | |
| | | //商铺类型查询起租时间 |
| | | if (roomDto.getRoomType().equals(RoomDto.ROOM_TYPE_SHOPS)) { |
| | | OwnerRoomRelDto ownerRoomRelDto = new OwnerRoomRelDto(); |
| | | ownerRoomRelDto.setRoomId(roomDto.getRoomId()); |
| | | ownerRoomRelDto.setStatusCd("0"); |
| | | List<OwnerRoomRelDto> ownerRoomRelDtoList = ownerRoomRelInnerServiceSMOImpl.queryOwnerRoomRels(ownerRoomRelDto); |
| | | if (ownerRoomRelDtoList != null && ownerRoomRelDtoList.size() == 1) { |
| | | roomDto.setStartTime(ownerRoomRelDtoList.get(0).getStartTime()); |
| | | roomDto.setEndTime(ownerRoomRelDtoList.get(0).getEndTime()); |
| | | } |
| | | } |
| | | // if (roomDto.getRoomType().equals(RoomDto.ROOM_TYPE_SHOPS)) { |
| | | // OwnerRoomRelDto ownerRoomRelDto = new OwnerRoomRelDto(); |
| | | // ownerRoomRelDto.setRoomId(roomDto.getRoomId()); |
| | | // ownerRoomRelDto.setStatusCd("0"); |
| | | // List<OwnerRoomRelDto> ownerRoomRelDtoList = ownerRoomRelInnerServiceSMOImpl.queryOwnerRoomRels(ownerRoomRelDto); |
| | | // if (ownerRoomRelDtoList != null && ownerRoomRelDtoList.size() == 1) { |
| | | // roomDto.setStartTime(ownerRoomRelDtoList.get(0).getStartTime()); |
| | | // roomDto.setEndTime(ownerRoomRelDtoList.get(0).getEndTime()); |
| | | // } |
| | | // } |
| | | } |
| | | } |
| | | } |