package com.yuchen.saas.park.service.service.property.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuchen.saas.park.api.dto.approve.PeopleApproveQueryDto;
import com.yuchen.saas.park.api.dto.approve.ResponseDataTypeDto;
import com.yuchen.saas.park.api.dto.property.NewHouseReq;
import com.yuchen.saas.park.api.dto.property.PropertyMoveInBatchDto;
import com.yuchen.saas.park.api.dto.property.PropertyMoveInRegisterQryDto;
import com.yuchen.saas.park.api.entity.approve.PeopleApprove;
import com.yuchen.saas.park.api.entity.approve.SaasGenericConfig;
import com.yuchen.saas.park.api.entity.park.PmgBatParkPeople;
import com.yuchen.saas.park.api.entity.property.PropertyHouses;
import com.yuchen.saas.park.api.entity.property.PropertyMoveInRegister;
import com.yuchen.saas.park.api.enums.approve.ApproveConfigGroupEnum;
import com.yuchen.saas.park.api.vo.property.PropertyMoveInRegisterListVo;
import com.yuchen.saas.park.api.vo.property.PropertyMoveInRegisterVo;
import com.yuchen.saas.park.service.mapper.property.PropertyMoveInRegisterMapper;
import com.yuchen.saas.park.service.service.PmgBatParkPeopleService;
import com.yuchen.saas.park.service.service.approve.ISaasGenericConfigService;
import com.yuchen.saas.park.service.service.approve.PeopleApproveService;
import com.yuchen.saas.park.service.service.property.IPropertyMoveInRegisterService;
import com.yuchen.saas.park.service.service.property.PropertyHousesService;
import com.yuchen.saas.parking.api.dto.ParkingPlacePersonSyncDTO;
import com.yuchen.saas.parking.api.dto.ParkingPlaceSyncDTO;
import com.yuchen.saas.parking.api.feign.ParkingPlaceClient;
import org.nest.springwrap.core.mp.base.BaseServiceImpl;
import org.nest.springwrap.core.tool.api.R;
import org.nest.springwrap.core.tool.utils.BeanUtil;
import org.nest.springwrap.core.tool.utils.Func;
import org.nest.springwrap.core.tool.utils.StringUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * <p>
 * 入住登记表 服务实现类
 * </p>
 *
 * @author 洪铭铭
 * @since 2024-11-29
 */
@Service
public class PropertyMoveInRegisterServiceImpl extends BaseServiceImpl<PropertyMoveInRegisterMapper, PropertyMoveInRegister> implements IPropertyMoveInRegisterService {

    @Resource
    PmgBatParkPeopleService pmgBatParkPeopleService;

    @Resource
    ISaasGenericConfigService saasGenericConfigService;

    @Resource
    PeopleApproveService peopleApproveService;
    @Resource
    ParkingPlaceClient parkingPlaceClient;

    @Resource
    PropertyHousesService propertyHousesService;


    public Page<PropertyMoveInRegister> selectPage(PropertyMoveInRegisterQryDto qryDto) {
        Page<PropertyMoveInRegister> page = new Page<>(qryDto.getCurrent(), qryDto.getSize());
        LambdaQueryWrapper<PropertyMoveInRegister> qw = new LambdaQueryWrapper<>();
//        if (!AuthUtil.isAdministrator()) {
//            qw.eq(PropertyMoveInRegister::getCustomerManageId, AuthUtil.getUser().getCustomerManageId());
//        } else {
//            // 超管
//            qw.eq(Func.isNotEmpty(qryDto.getCustomerManageId()), PropertyMoveInRegister::getCustomerManageId, qryDto.getCustomerManageId());
//        }
        qw.eq(Func.isNotEmpty(qryDto.getParkId()), PropertyMoveInRegister::getParkId, qryDto.getParkId());
        qw.eq(Func.isNotEmpty(qryDto.getBuildingId()), PropertyMoveInRegister::getBuildingId, qryDto.getBuildingId());
        qw.eq(Func.isNotEmpty(qryDto.getResourceCode()), PropertyMoveInRegister::getResourceCode, qryDto.getResourceCode());
        qw.eq(Func.isNotEmpty(qryDto.getRoomName()), PropertyMoveInRegister::getRoomName, qryDto.getRoomName());
        return this.page(page, qw);
    }

    public Boolean addBatch(PropertyMoveInBatchDto batchDto) {
        return false;
    }

    public R confirm(NewHouseReq newHouseReq) {
        ResponseDataTypeDto responseDataTypeDto = new ResponseDataTypeDto();

        LambdaQueryWrapper<PmgBatParkPeople> qw = new LambdaQueryWrapper<>();
        qw.eq(Func.isNotEmpty(newHouseReq.getRoomId()), PmgBatParkPeople::getRoomId, newHouseReq.getRoomId());
        qw.eq(PmgBatParkPeople::getPeopleType, 1);
        qw.eq(Func.isNotEmpty(newHouseReq.getName()), PmgBatParkPeople::getName, newHouseReq.getName());
        qw.eq(Func.isNotEmpty(newHouseReq.getPhone()), PmgBatParkPeople::getPhone, newHouseReq.getPhone());
        qw.eq(Func.isNotEmpty(newHouseReq.getIdCard()), PmgBatParkPeople::getIdCard, newHouseReq.getIdCard());
        List<PmgBatParkPeople> list = pmgBatParkPeopleService.list(qw);

        if (Func.isNotEmpty(list) && list.size() > 0) {
            //姓名 电话 身份照证 有存在
            PmgBatParkPeople pmgBatParkPeople = list.get(0);
            if (Func.isNotEmpty(pmgBatParkPeople.getPeopleType()) && pmgBatParkPeople.getPeopleType().intValue() == ApproveConfigGroupEnum.OWNER_APPROVE.getValue()) {
                //业主审核
                SaasGenericConfig config = saasGenericConfigService.getConfigValue(ApproveConfigGroupEnum.OWNER_APPROVE.getDesc());
                if (StringUtil.equals(config.getConfigGroupValue(), "2")) {
                    //需要物业审核
                    PeopleApprove app = BeanUtil.copyProperties(pmgBatParkPeople, PeopleApprove.class);
                    app.setContactPhone(pmgBatParkPeople.getPhone());
                    app.setApproveType(pmgBatParkPeople.getPeopleType().intValue());
                    app.setApplyTime(new Date());
                    app.setApplyStatus("1");
                    app.setParkName(pmgBatParkPeople.getParkName());
                    app.setBuildingName(pmgBatParkPeople.getBuildingName());
                    app.setBuildingUnitName(pmgBatParkPeople.getBuildingUnitName());
                    app.setRoomName(pmgBatParkPeople.getRoomName());
                    PeopleApproveQueryDto exist = BeanUtil.copyProperties(pmgBatParkPeople, PeopleApproveQueryDto.class);
                    exist.setApproveType(pmgBatParkPeople.getPeopleType().intValue());
                    Page<PeopleApprove> res = peopleApproveService.getExistApproveList(exist);
                    if (Func.isNotEmpty(res.getRecords())) {
                        PeopleApprove record = res.getRecords().get(0);
                        if (record.getApplyStatus().equals("4")) {
                            //驳回后,重复提交的改回待审核
                            record.setApplyStatus("1");
                            peopleApproveService.saveOrUpdate(record);
                            //return R.success("业主信息已提交，请等待审核");
                        }
                        //return R.fail("业主信息已提交，请勿重复提交");
                    }

                    peopleApproveService.savePeopleApprove(app);
                    //return R.success("业主信息已提交，请等待审核");
                } else {
                    //不需要物业审核
                    pmgBatParkPeople.setBindStatus(1);
                    pmgBatParkPeople.setBindAccount(newHouseReq.getPhone());
                    pmgBatParkPeopleService.saveOrUpdate(pmgBatParkPeople);
                    //return R.success("认证成功");
                }

            } //else if (Func.isNotEmpty(pmgBatParkPeople.getPeopleType()) && pmgBatParkPeople.getPeopleType().intValue() == ApproveConfigGroupEnum.RESIDENT_APPROVE.getValue()) {
            else {
                //非业主审核的其他peopleType走这边
                //住户审核
                SaasGenericConfig config = saasGenericConfigService.getConfigValue(ApproveConfigGroupEnum.RESIDENT_APPROVE.getDesc());
                if (StringUtil.equals(config.getConfigGroupValue(), "2")) {
                    //需要物业审核
                    PeopleApprove app = BeanUtil.copyProperties(pmgBatParkPeople, PeopleApprove.class);
                    app.setContactPhone(pmgBatParkPeople.getPhone());
                    app.setApproveType(pmgBatParkPeople.getPeopleType().intValue());
                    app.setApplyTime(new Date());
                    app.setApplyStatus("1");
                    app.setParkName(pmgBatParkPeople.getParkName());
                    app.setBuildingName(pmgBatParkPeople.getBuildingName());
                    app.setBuildingUnitName(pmgBatParkPeople.getBuildingUnitName());
                    app.setRoomName(pmgBatParkPeople.getRoomName());
                    PeopleApproveQueryDto exist = BeanUtil.copyProperties(pmgBatParkPeople, PeopleApproveQueryDto.class);
                    exist.setApproveType(pmgBatParkPeople.getPeopleType().intValue());
                    Page<PeopleApprove> res = peopleApproveService.getPeopleApproveList(exist);
                    if (Func.isNotEmpty(res.getRecords())) {
                        PeopleApprove record = res.getRecords().get(0);
                        if (record.getApplyStatus().equals("4")) {
                            record.setApplyStatus("1");
                            peopleApproveService.saveOrUpdate(record);
                            //return R.success("住户信息已提交，请等待审核");
//                            responseDataTypeDto.setValue(1);
//                            return R.data("200", responseDataTypeDto, "业主信息已提交，请等待审核");
                        }
                        //return R.fail("住户信息已提交，请勿重复提交");
//                        responseDataTypeDto.setValue(2);
//                        return R.data("200", responseDataTypeDto, "业主信息已提交，请勿重复提交");
                    }
                    peopleApproveService.savePeopleApprove(app);
                    //return R.success("住户信息已提交，请等待审核");
//                    responseDataTypeDto.setValue(1);
//                    return R.data("200", responseDataTypeDto, "业主信息已提交，请等待审核");
                } else {
                    //不需要住户审核
                    pmgBatParkPeople.setBindStatus(1);
                    pmgBatParkPeople.setBindAccount(pmgBatParkPeople.getPhone());
                    pmgBatParkPeopleService.saveOrUpdate(pmgBatParkPeople);
                    //return R.success("认证成功");
//                    responseDataTypeDto.setValue(0);
//                    return R.data("200", responseDataTypeDto, "认证成功");
                }
            }
        } else {

            // 姓名 电话 身份照证 不存在
            //if (Func.isNotEmpty(pmgBatParkPeopleQryDto.getPeopleType()) && pmgBatParkPeopleQryDto.getPeopleType().intValue() == ApproveConfigGroupEnum.OWNER_APPROVE.getValue()) {
            //业主审核
            SaasGenericConfig config = saasGenericConfigService.getConfigValue(ApproveConfigGroupEnum.OWNER_APPROVE.getDesc());
            if (StringUtil.equals(config.getConfigGroupValue(), "2")) {
                //需要业主审核
                PeopleApprove app = BeanUtil.copyProperties(newHouseReq, PeopleApprove.class);
                app.setContactPhone(newHouseReq.getPhone());
                app.setApproveType(1);
                app.setApplyTime(new Date());
                app.setApplyStatus("1");
                app.setParkName(newHouseReq.getParkName());
                app.setBuildingName(newHouseReq.getBuildingName());
                app.setBuildingUnitName(newHouseReq.getBuildingUnitName());
                app.setRoomName(newHouseReq.getRoomName());
                PeopleApproveQueryDto exist = BeanUtil.copyProperties(newHouseReq, PeopleApproveQueryDto.class);
                exist.setApproveType(1);
                Page<PeopleApprove> res = peopleApproveService.getExistApproveList(exist);
                if (Func.isNotEmpty(res.getRecords())) {
                    PeopleApprove record = res.getRecords().get(0);
                    if (record.getApplyStatus().equals("4")) {
                        record.setApplyStatus("1");
                        peopleApproveService.saveOrUpdate(record);
                        //return R.success("业主信息已提交，请等待审核");
                        responseDataTypeDto.setValue(1);
                        return R.data("200", responseDataTypeDto, "业主信息已提交，请等待审核");
                    }
                    responseDataTypeDto.setValue(2);
                    //return R.fail("业主信息已提交，请勿重复提交");
                    return R.data("200", responseDataTypeDto, "业主信息已提交，请勿重复提交");
                }

                peopleApproveService.savePeopleApprove(app);
                //return R.success("业主信息已提交，请等待审核");
                //responseDataTypeDto.setValue(1);
                //return R.data("200", responseDataTypeDto, "业主信息已提交，请等待审核");
            }
//                else {
//                    pmgBatParkPeopleQryDto.setBindStatus(1);
//                    pmgBatParkPeopleQryDto.setBindAccount(pmgBatParkPeopleQryDto.getPhone());
//                    PmgBatParkPeople people = new PmgBatParkPeople();
//                    BeanUtil.copyProperties(pmgBatParkPeopleQryDto, people);
//                    this.saveOrUpdate(people);
//                    //return R.success("认证成功");
//                    responseDataTypeDto.setValue(0);
//                    return R.data("200", responseDataTypeDto, "认证成功");
//                }
            //}else{
            //非业主审核的其他peopleType走这边
            //if (Func.isNotEmpty(pmgBatParkPeopleQryDto.getPeopleType()) && pmgBatParkPeopleQryDto.getPeopleType().intValue() == ApproveConfigGroupEnum.RESIDENT_APPROVE.getValue()) {
            SaasGenericConfig config2 = saasGenericConfigService.getConfigValue(ApproveConfigGroupEnum.RESIDENT_APPROVE.getDesc());
            if (StringUtil.equals(config2.getConfigGroupValue(), "2")) {
                for (PmgBatParkPeople occupier : newHouseReq.getOccupiers()) {
                    //需要业主审核
                    PeopleApprove app = BeanUtil.copyProperties(occupier, PeopleApprove.class);
                    app.setContactPhone(occupier.getPhone());
                    app.setApproveType(occupier.getPeopleType().intValue());
                    app.setApplyTime(new Date());
                    app.setApplyStatus("1");
                    app.setParkName(occupier.getParkName());
                    app.setBuildingName(occupier.getBuildingName());
                    app.setBuildingUnitName(occupier.getBuildingUnitName());
                    app.setRoomName(occupier.getRoomName());
                    PeopleApproveQueryDto exist = BeanUtil.copyProperties(occupier, PeopleApproveQueryDto.class);
                    exist.setApproveType(occupier.getPeopleType().intValue());
                    Page<PeopleApprove> res = peopleApproveService.getPeopleApproveList(exist);
                    if (Func.isNotEmpty(res.getRecords())) {
                        PeopleApprove record = res.getRecords().get(0);
                        if (record.getApplyStatus().equals("4")) {
                            record.setApplyStatus("1");
                            peopleApproveService.saveOrUpdate(record);
                            //responseDataTypeDto.setValue(1);
                            //return R.success("住户信息已提交，请等待审核");
                        }
                        //return R.fail("住户信息已提交，请勿重复提交");
                        //responseDataTypeDto.setValue(2);
                        //return R.data("200", responseDataTypeDto, "业主信息已提交，请勿重复提交");
                    }
                    peopleApproveService.savePeopleApprove(app);
                }
                    //return R.success("住户信息已提交，请等待审核");
                    //responseDataTypeDto.setValue(1);
                    //return R.data("200", responseDataTypeDto, "业主信息已提交，请等待审核");
                } else{
//                    pmgBatParkPeople.setBindStatus(1);
//                    pmgBatParkPeople.setBindAccount(pmgBatParkPeopleQryDto.getPhone());
//                    this.saveOrUpdate(pmgBatParkPeople);
//                    return R.success("认证成功");
                }

        }
            //}

            //responseDataTypeDto.setValue(3);
            //return R.data("200", responseDataTypeDto, "未查到人员信息，请移步至服务中心更新业主信息");
            //return R.fail("未查到人员信息，请移步至服务中心更新业主信息");

       return R.success("操作成功");


    }

    public R confirmNoApprove(NewHouseReq newHouseReq) {

        PmgBatParkPeople owner = new PmgBatParkPeople();
        BeanUtils.copyProperties(newHouseReq, owner);
        owner.setPeopleType(1l);
        owner.setBindStatus(1);
        owner.setBindAccount(newHouseReq.getPhone());
        pmgBatParkPeopleService.saveOrUpdate(owner);

        for (PmgBatParkPeople occupier : newHouseReq.getOccupiers()) {
            PmgBatParkPeople save = new PmgBatParkPeople();
            BeanUtils.copyProperties(occupier, save);
            save.setParkId(newHouseReq.getParkId());
            save.setBuildingId(newHouseReq.getBuildingId());
            save.setBuildingUnitId(newHouseReq.getBuildingUnitId());
            save.setFloorId(newHouseReq.getFloorId());
            save.setRoomId(newHouseReq.getRoomId());
            save.setBindStatus(1);
            save.setBindAccount(newHouseReq.getPhone());
            pmgBatParkPeopleService.saveOrUpdate(save);
        }
        List<ParkingPlacePersonSyncDTO> spaceList = new ArrayList<>();
        for(NewHouseReq.ParkingPlacePersonSyncDTO dto : newHouseReq.getCars()) {
            ParkingPlacePersonSyncDTO parking = new ParkingPlacePersonSyncDTO();
            BeanUtils.copyProperties(dto, parking);
            spaceList.add(parking);
        }

        parkingPlaceClient.syncPlacePerson(spaceList);


        List<ParkingPlaceSyncDTO> syncList = new ArrayList<>();
        for(NewHouseReq.ParkingPlaceSyncDTO dto : newHouseReq.getParkingSpace()) {
            ParkingPlaceSyncDTO place = new ParkingPlaceSyncDTO();
            BeanUtils.copyProperties(dto, place);
            syncList.add(place);
        }

        parkingPlaceClient.syncPlace(syncList);

        return R.success("操作成功");


    }

    public R<PropertyMoveInRegisterVo> detail(@RequestParam("roomId") Long roomId) {
        PropertyMoveInRegisterVo vo = new PropertyMoveInRegisterVo();
        PropertyHouses house = propertyHousesService.getById(roomId);
        vo.setConstructionArea(house.getConstructionArea());
        vo.setInternalArea(house.getInternalArea());
        vo.setFeeArea(house.getFeeArea());

        List<PropertyMoveInRegister> list = new ArrayList<>();
        LambdaQueryWrapper<PropertyMoveInRegister> qw = new LambdaQueryWrapper<>();
        qw.eq(PropertyMoveInRegister::getRoomId, roomId);
        qw.eq(PropertyMoveInRegister::getType, 1);
        //list = this.list(qw).stream().filter(item->item.getOccupierType() != 1).collect(Collectors.toList());
        list = this.list(qw);
        List<PmgBatParkPeople> listPeople = new ArrayList<>();
        for (PropertyMoveInRegister regi : list) {
            PmgBatParkPeople p = pmgBatParkPeopleService.getById(regi.getOccupierId());
            listPeople.add(p);
        }

        vo.setOccupiers(listPeople);

        List<PropertyMoveInRegister> listParkingSpace = new ArrayList<>();
        LambdaQueryWrapper<PropertyMoveInRegister> qwParkingSpace = new LambdaQueryWrapper<>();
        qwParkingSpace.eq(PropertyMoveInRegister::getRoomId, roomId);
        qwParkingSpace.eq(PropertyMoveInRegister::getType, 2);
        //list = this.list(qw).stream().filter(item->item.getOccupierType() != 1).collect(Collectors.toList());
        listParkingSpace = this.list(qwParkingSpace);

        List<NewHouseReq.ParkingPlaceSyncDTO> sync = new ArrayList<>();
        for (PropertyMoveInRegister regi : listParkingSpace) {
            NewHouseReq.ParkingPlaceSyncDTO dto = new NewHouseReq.ParkingPlaceSyncDTO();
            dto.setPlaceId(regi.getCarSpaceId());
//            dto.setPeopleId();
            sync.add(dto);
        }


        vo.setParkingSpace(sync);

        List<PropertyMoveInRegister> listCar = new ArrayList<>();
        LambdaQueryWrapper<PropertyMoveInRegister> qwCar = new LambdaQueryWrapper<>();
        qwParkingSpace.eq(PropertyMoveInRegister::getRoomId, roomId);
        qwParkingSpace.eq(PropertyMoveInRegister::getType, 3);
        //list = this.list(qw).stream().filter(item->item.getOccupierType() != 1).collect(Collectors.toList());
        listCar = this.list(qwCar);

        List<NewHouseReq.ParkingPlacePersonSyncDTO> syncCar = new ArrayList<>();
        for (PropertyMoveInRegister regi : listCar) {
            NewHouseReq.ParkingPlacePersonSyncDTO dto = new NewHouseReq.ParkingPlacePersonSyncDTO();
            dto.setPlateNo(regi.getCarName());

            syncCar.add(dto);
        }


        vo.setCars(syncCar);


        return R.data(vo);
    }

    @Override
    public R<List<PropertyMoveInRegisterListVo>> list(PropertyMoveInRegisterQryDto qryDto) {

        List<PropertyMoveInRegisterListVo> vo = new ArrayList<>();

        Page<PmgBatParkPeople> page = new Page<>(qryDto.getCurrent(), qryDto.getSize());
        LambdaQueryWrapper<PropertyMoveInRegister> qw = new LambdaQueryWrapper<>();

        qw.eq(Func.isNotEmpty(qryDto.getBuildingId()), PropertyMoveInRegister::getBuildingId, qryDto.getBuildingId());

        qw.eq(Func.isNotEmpty(qryDto.getParkId()), PropertyMoveInRegister::getParkId, qryDto.getParkId());
        qw.like(Func.isNotEmpty(qryDto.getRoomName()), PropertyMoveInRegister::getRoomName, qryDto.getRoomName());
        qw.eq(Func.isNotEmpty(qryDto.getResourceCode()), PropertyMoveInRegister::getResourceCode, qryDto.getResourceCode());

        qw.orderByDesc(PropertyMoveInRegister::getCreateTime);
        List<PropertyMoveInRegister> propertyMoveInRegisterList = this.list(qw);

        QueryWrapper<PropertyMoveInRegister> qw2 = new QueryWrapper<>();

        qw2.select("distinct room_id");
        List<PropertyMoveInRegister> roomIds = this.list(qw2);

        for (PropertyMoveInRegister roomId : roomIds) {
            Long id = roomId.getRoomId();
            List<PropertyMoveInRegister> houseList = propertyMoveInRegisterList.stream().filter(item -> Objects.equals(item.getRoomId(), id)).collect(Collectors.toList());
            PropertyMoveInRegisterListVo entry = new PropertyMoveInRegisterListVo();
            BeanUtils.copyProperties(houseList.get(0), entry);
            // 车位列表
            List<PropertyMoveInRegister> spaceList = propertyMoveInRegisterList.stream().filter(item -> Objects.equals(item.getRoomId(), id) && item.getType() == 2).collect(Collectors.toList());
            List<NewHouseReq.ParkingPlaceSyncDTO> parkingList = new ArrayList<>();
            for (PropertyMoveInRegister space : spaceList) {
                NewHouseReq.ParkingPlaceSyncDTO placeSyncDTO = new NewHouseReq.ParkingPlaceSyncDTO();
                BeanUtils.copyProperties(space, placeSyncDTO);
                placeSyncDTO.setPlaceId(space.getCarSpaceId());
                placeSyncDTO.setPersonName(space.getCarSpaceName());
                parkingList.add(placeSyncDTO);
            }
            entry.setParkingSpace(parkingList);
            // 车辆列表
            List<PropertyMoveInRegister> carList = propertyMoveInRegisterList.stream().filter(item -> Objects.equals(item.getRoomId(), id) && item.getType() == 3).collect(Collectors.toList());
            List<NewHouseReq.ParkingPlacePersonSyncDTO> carsList = new ArrayList<>();
            for (PropertyMoveInRegister car : carList) {
                NewHouseReq.ParkingPlacePersonSyncDTO placePersonSyncDTO = new NewHouseReq.ParkingPlacePersonSyncDTO();
                BeanUtils.copyProperties(car, placePersonSyncDTO);
                placePersonSyncDTO.setCarId(car.getCarId());
                placePersonSyncDTO.setPlateNo(car.getCarName());
                carsList.add(placePersonSyncDTO);
            }
            entry.setCars(carsList);
            vo.add(entry);
        }












//        PropertyHouses house = propertyHousesService.getById(roomId);
//        vo.setConstructionArea(house.getConstructionArea());
//        vo.setInternalArea(house.getInternalArea());
//        vo.setFeeArea(house.getFeeArea());
//
//        List<PropertyMoveInRegister> list = new ArrayList<>();
//        LambdaQueryWrapper<PropertyMoveInRegister> qw = new LambdaQueryWrapper<>();
//        qw.eq(PropertyMoveInRegister::getRoomId, roomId);
//        qw.eq(PropertyMoveInRegister::getType, 1);
//        //list = this.list(qw).stream().filter(item->item.getOccupierType() != 1).collect(Collectors.toList());
//        list = this.list(qw);
//        List<PmgBatParkPeople> listPeople = new ArrayList<>();
//        for (PropertyMoveInRegister regi : list) {
//            PmgBatParkPeople p = pmgBatParkPeopleService.getById(regi.getOccupierId());
//            listPeople.add(p);
//        }
//
//        vo.setOccupiers(listPeople);
//
//        List<PropertyMoveInRegister> listParkingSpace = new ArrayList<>();
//        LambdaQueryWrapper<PropertyMoveInRegister> qwParkingSpace = new LambdaQueryWrapper<>();
//        qwParkingSpace.eq(PropertyMoveInRegister::getRoomId, roomId);
//        qwParkingSpace.eq(PropertyMoveInRegister::getType, 2);
//        //list = this.list(qw).stream().filter(item->item.getOccupierType() != 1).collect(Collectors.toList());
//        listParkingSpace = this.list(qwParkingSpace);
//
//        List<NewHouseReq.ParkingPlaceSyncDTO> sync = new ArrayList<>();
//        for (PropertyMoveInRegister regi : listParkingSpace) {
//            NewHouseReq.ParkingPlaceSyncDTO dto = new NewHouseReq.ParkingPlaceSyncDTO();
//            dto.setPlaceId(regi.getCarSpaceId());
////            dto.setPeopleId();
//            sync.add(dto);
//        }
//
//
//        vo.setParkingSpace(sync);
//
//        List<PropertyMoveInRegister> listCar = new ArrayList<>();
//        LambdaQueryWrapper<PropertyMoveInRegister> qwCar = new LambdaQueryWrapper<>();
//        qwParkingSpace.eq(PropertyMoveInRegister::getRoomId, roomId);
//        qwParkingSpace.eq(PropertyMoveInRegister::getType, 3);
//        //list = this.list(qw).stream().filter(item->item.getOccupierType() != 1).collect(Collectors.toList());
//        listCar = this.list(qwCar);
//
//        List<NewHouseReq.ParkingPlacePersonSyncDTO> syncCar = new ArrayList<>();
//        for (PropertyMoveInRegister regi : listCar) {
//            NewHouseReq.ParkingPlacePersonSyncDTO dto = new NewHouseReq.ParkingPlacePersonSyncDTO();
//            dto.setPlateNo(regi.getCarName());
//
//            syncCar.add(dto);
//        }
//
//
//        vo.setCars(syncCar);

    return R.data(vo);
        //return R.data(vo);
    }


}
