/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.person.service.impl;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Assert;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springblade.common.constant.CommonConstant;
import org.springblade.common.constant.OperationConstant;
import org.springblade.community.entity.*;
import org.springblade.community.feign.*;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.constant.BladeConstant;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.device.dto.DispatchTask;
import org.springblade.device.dto.UserInfoDto;
import org.springblade.device.feign.IDoorDeviceClient;
import org.springblade.estate.entity.ApplyUser;
import org.springblade.estate.feign.IApplyUserClient;
import org.springblade.estate.vo.ApplyUserVO;
import org.springblade.person.dto.HouseUserDTO;
import org.springblade.person.entity.*;
import org.springblade.person.feign.IMemberClient;
import org.springblade.person.mapper.HouseUserMapper;
import org.springblade.person.service.*;
import org.springblade.person.vo.HouseUserVO;
import org.springblade.system.expand.feign.IConfClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.transaction.annotation.Transactional;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 *  服务实现类
 *
 * @author BladeX
 * @since 2021-04-14
 */
@Service
public class HouseUserServiceImpl extends BaseServiceImpl<HouseUserMapper, HouseUser> implements HouseUserService, IUserService<HouseUser> {

	private final ICommunityClient communityClient;
	private final IApplyUserClient applyUserClient;
	private final IMemberClient memberClient;
	private final IDoorDeviceClient doorDeviceClient;
	private final IConfClient confClient;
	private final IAgencyClient agencyClient;
	private final IResidentialClient residentialClient;
	private final IBuildingClient buildingClient;
	private final IUnitClient unitClient;
	private final IFloorClient floorClient;
	private final IRoomClient roomClient;
	private final IElderlyPeopleService elderlyPeopleService;
	private final IKeyPeopleService keyPeopleService;
	private final IDisablerService disablerService;
	private final IDrugService drugService;
	private final IAdolescentService adolescentService;
	private final IAidsService aidsService;
	private final ICorrectionalStaffService correctionalStaffService;
	private final IEstablishFilecardService establishFilecardService;
	private final IFertileWomanService fertileWomanService;
	private final IPrisonerService prisonerService;
	private final IPsychiatricService psychiatricService;
	private final IVeteransService veteransService;
	private final IAllowancesPeopleService allowancesPeopleService;

	@Autowired
	public HouseUserServiceImpl(ICommunityClient communityClient,IApplyUserClient applyUserClient,IMemberClient memberClient,
								IDoorDeviceClient doorDeviceClient, IConfClient confClient, IAgencyClient agencyClient, IResidentialClient residentialClient
		, IBuildingClient buildingClient, IUnitClient unitClient, IFloorClient floorClient, IRoomClient roomClient
		, IElderlyPeopleService elderlyPeopleService, IKeyPeopleService keyPeopleService, IDisablerService disablerService, IDrugService drugService, IAdolescentService adolescentService
		, IAidsService aidsService, ICorrectionalStaffService correctionalStaffService, IFertileWomanService fertileWomanService, IPrisonerService prisonerService
		, IPsychiatricService psychiatricService, IVeteransService veteransService, IAllowancesPeopleService allowancesPeopleService, IEstablishFilecardService establishFilecardService){
		this.communityClient = communityClient;
		this.applyUserClient = applyUserClient;
		this.memberClient = memberClient;
		this.doorDeviceClient = doorDeviceClient;
		this.confClient = confClient;
		this.agencyClient = agencyClient;
		this.residentialClient = residentialClient;
		this.buildingClient = buildingClient;
		this.unitClient = unitClient;
		this.floorClient = floorClient;
		this.roomClient = roomClient;
		this.elderlyPeopleService = elderlyPeopleService;
		this.keyPeopleService = keyPeopleService;
		this.disablerService = disablerService;
		this.drugService = drugService;
		this.adolescentService = adolescentService;
		this.aidsService = aidsService;
		this.correctionalStaffService = correctionalStaffService;
		this.establishFilecardService = establishFilecardService;
		this.fertileWomanService = fertileWomanService;
		this.prisonerService = prisonerService;
		this.psychiatricService = psychiatricService;
		this.veteransService = veteransService;
		this.allowancesPeopleService = allowancesPeopleService;
	}

	@Override
	public IPage<HouseUserVO> selectBasicInfoPage(IPage<HouseUserVO> page, HouseUserVO basicInfo) {
		return page.setRecords(baseMapper.selectBasicInfoPage(page, basicInfo));
	}

	@Override
	@Transactional
	public boolean deleteUserAndRelationship(HouseUserDTO userDto) {
		HouseUser user = this.getById(userDto.getId());
		if (null == user) {
			return false;
		}
		//状态删除
		Boolean result = this.removeById(userDto.getId());
		if(result){
			//修改住户数量

			this.communityClient.subPersonNum(user.getAgencyId(),user.getResidentialId(),user.getBuildingId(),user.getUnitId()
			   ,user.getFloorId(),user.getRoomId());

			//处理删除user后，与之关联的会员状态
			result = this.dealMemberState(userDto.getId());
		}
		return  result;
	}

	@Override
	public Integer houseUserStat(String beginDate, String endDate) {
		BladeUser bladeUser = AuthUtil.getUser();
		QueryWrapper<HouseUser> queryWrapper = Condition.getQueryWrapper(new HashMap<>(), HouseUser.class);
		if(!bladeUser.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID)){  //超管
			queryWrapper.lambda().eq(HouseUser::getTenantId, bladeUser.getTenantId());
		}else{

		}
		if(StringUtil.isNotBlank(beginDate) && StringUtil.isNotBlank(endDate)){
			queryWrapper.lambda().ge(HouseUser::getCreateTime, beginDate);
			queryWrapper.lambda().le(HouseUser::getCreateTime, endDate);
		}else{
			Date today = new Date();
			DateTime dateTime = DateUtil.beginOfDay(today);
			queryWrapper.lambda().ge(HouseUser::getCreateTime, dateTime);
			DateTime endTime = DateUtil.endOfDay(today);
			queryWrapper.lambda().le(HouseUser::getCreateTime, endTime);
		}
		return this.count(queryWrapper);
	}

	@Override
	public R submit(HouseUserDTO houseUserDTO) {
		Residential residential = residentialClient.getById(houseUserDTO.getResidentialId());
		Assert.notNull(residential, "小区不存在");
		Agency agency = agencyClient.getById(residential.getAgencyId());
		Assert.notNull(agency, "社区不存在");
		houseUserDTO.setAgencyId(agency.getId());
		houseUserDTO.setAgencyName(agency.getName());
		houseUserDTO.setResidentialName(residential.getName());
		if (houseUserDTO.getBuildingId() != null) {
			Building building = buildingClient.getById(houseUserDTO.getBuildingId());
			Assert.notNull(building, "选择的楼栋不存在");
			houseUserDTO.setBuildingName(building.getName());
		}
		if (houseUserDTO.getUnitId() != null) {
			Unit unit = unitClient.getById(houseUserDTO.getUnitId());
			Assert.notNull(unit, "选择的单元不存在");
			houseUserDTO.setUnitName(unit.getName());
		}
		if (houseUserDTO.getFloorId() != null) {
			Floor floor = floorClient.getById(houseUserDTO.getFloorId());
			Assert.notNull(floor, "选择的楼层不存在");
			houseUserDTO.setFloorName(floor.getName());
		}
		if (houseUserDTO.getRoomId() != null) {
			Room room = roomClient.getById(houseUserDTO.getRoomId());
			Assert.notNull(room, "选择的房间不存在");
			houseUserDTO.setRoomName(room.getName());
		}
		houseUserDTO.setFaceUrl(confClient.removePrefix(houseUserDTO.getFaceUrl()));
		boolean saveOrUpdate = this.saveOrUpdate(houseUserDTO);
		if(saveOrUpdate){
			submitUserTags(houseUserDTO);
		}
		return R.status(saveOrUpdate);
//		if (saveOrUpdate) {
//			//下发人脸
//			if (StringUtil.isNotBlank(houseUserDTO.getFaceUrl())) {
//				houseUserDTO.setFaceUrl(confClient.addPrefix(houseUserDTO.getFaceUrl()));
//				R result = houseUserDTO.pushAddFace(houseUserDTO, new HashMap<>());
//				if (result.isSuccess()) {
//					return R.success("保存住户成功");
//				} else {
//					return R.fail("保存住户成功，人脸下发失败");
//				}
//			} else {
//				return R.success("保存住户成功");
//			}
//		} else {
//			return R.fail("保存住户失败");
//		}
	}

	@Override
	public void submitUserTags(HouseUser houseUser) {
		if(StringUtil.isBlank(houseUser.getTags())){
			return;
		}
		if (houseUser.getTags().contains("高龄老人")) {
			//判断原来是否存在
			ElderlyPeople ifelderlyPeople = elderlyPeopleService.getBaseMapper().selectOne(new QueryWrapper<>(new ElderlyPeople()).eq("parent_id", houseUser.getId()));
			if (ifelderlyPeople == null) {//不存在则新增
				ElderlyPeople elderlyPeople = new ElderlyPeople();
				elderlyPeople.setParentId(houseUser.getId());
				elderlyPeople.setName(houseUser.getName());
				elderlyPeopleService.save(elderlyPeople);
			}
		} else {
			//修改时取消了该标签则删除
			ElderlyPeople ifelderlyPeople = elderlyPeopleService.getBaseMapper().selectOne(new QueryWrapper<>(new ElderlyPeople()).eq("parent_id", houseUser.getId()));
			if (ifelderlyPeople != null) {//存在则逻辑删除
				elderlyPeopleService.getBaseMapper().delete(new QueryWrapper<ElderlyPeople>().eq("parent_id", houseUser.getId()));
			}
		}

		if (houseUser.getTags().contains("残障人士")) {
			//判断原来是否存在
			Disabler ifdisabler = disablerService.getBaseMapper().selectOne(new QueryWrapper<>(new Disabler()).eq("parent_id", houseUser.getId()));
			if (ifdisabler == null) {//不存在则新增
				Disabler disabler = new Disabler();
				disabler.setParentId(houseUser.getId());
				disabler.setName(houseUser.getName());
				disablerService.save(disabler);
			}
		} else {
			//修改时取消了该标签则删除
			Disabler ifdisabler = disablerService.getBaseMapper().selectOne(new QueryWrapper<>(new Disabler()).eq("parent_id", houseUser.getId()));
			if (ifdisabler != null) {//存在则逻辑删除
				disablerService.getBaseMapper().delete(new QueryWrapper<Disabler>().eq("parent_id", houseUser.getId()));
			}
		}

		if (houseUser.getTags().contains("吸毒人员")) {
			//判断原来是否存在
			Drug ifdrug = drugService.getBaseMapper().selectOne(new QueryWrapper<>(new Drug()).eq("parent_id", houseUser.getId()));
			if (ifdrug == null) {//不存在则新增
				Drug drug = new Drug();
				drug.setParentId(houseUser.getId());
				drug.setName(houseUser.getName());
				drugService.save(drug);
			}
		} else {
			//修改时取消了该标签则删除
			Drug ifdrug = drugService.getBaseMapper().selectOne(new QueryWrapper<>(new Drug()).eq("parent_id", houseUser.getId()));
			if (ifdrug != null) {//存在则逻辑删除
				drugService.getBaseMapper().delete(new QueryWrapper<Drug>().eq("parent_id", houseUser.getId()));
			}
		}

		if (houseUser.getTags().contains("重点青少年")) {
			//判断原来是否存在
			Adolescent ifadolescent = adolescentService.getBaseMapper().selectOne(new QueryWrapper<>(new Adolescent()).eq("parent_id", houseUser.getId()));
			if (ifadolescent == null) {//不存在则新增
				Adolescent adolescent = new Adolescent();
				adolescent.setParentId(houseUser.getId());
				adolescent.setName(houseUser.getName());
				adolescentService.save(adolescent);
			}
		} else {
			//修改时取消了该标签则删除
			CorrectionalStaff ifcorrectionalStaff = correctionalStaffService.getBaseMapper().selectOne(new QueryWrapper<>(new CorrectionalStaff()).eq("parent_id", houseUser.getId()));
			if (ifcorrectionalStaff != null) {//存在则逻辑删除
				correctionalStaffService.getBaseMapper().delete(new QueryWrapper<CorrectionalStaff>().eq("parent_id", houseUser.getId()));
			}
		}

		if (houseUser.getTags().contains("矫正人员")) {
			//判断原来是否存在
			CorrectionalStaff ifcorrectionalStaff = correctionalStaffService.getBaseMapper().selectOne(new QueryWrapper<>(new CorrectionalStaff()).eq("parent_id", houseUser.getId()));
			if (ifcorrectionalStaff == null) {//不存在则新增
				CorrectionalStaff correctionalStaff = new CorrectionalStaff();
				correctionalStaff.setParentId(houseUser.getId());
				correctionalStaff.setName(houseUser.getName());
				correctionalStaffService.save(correctionalStaff);
			}
		} else {
			//修改时取消了该标签则删除
			CorrectionalStaff ifcorrectionalStaff = correctionalStaffService.getBaseMapper().selectOne(new QueryWrapper<>(new CorrectionalStaff()).eq("parent_id", houseUser.getId()));
			if (ifcorrectionalStaff != null) {//存在则逻辑删除
				correctionalStaffService.getBaseMapper().delete(new QueryWrapper<CorrectionalStaff>().eq("parent_id", houseUser.getId()));
			}
		}

		if (houseUser.getTags().contains("建档立卡")) {
			//判断原来是否存在
			EstablishFilecard ifestablishFilecard = establishFilecardService.getBaseMapper().selectOne(new QueryWrapper<>(new EstablishFilecard()).eq("parent_id", houseUser.getId()));
			if (ifestablishFilecard == null) {//不存在则新增
				EstablishFilecard establishFilecard = new EstablishFilecard();
				establishFilecard.setParentId(houseUser.getId());
				establishFilecard.setName(houseUser.getName());
				establishFilecardService.save(establishFilecard);
			}
		} else {
			//修改时取消了该标签则删除
			EstablishFilecard ifestablishFilecard = establishFilecardService.getBaseMapper().selectOne(new QueryWrapper<>(new EstablishFilecard()).eq("parent_id", houseUser.getId()));
			if (ifestablishFilecard != null) {//存在则逻辑删除
				establishFilecardService.getBaseMapper().delete(new QueryWrapper<EstablishFilecard>().eq("parent_id", houseUser.getId()));
			}
		}

		if (houseUser.getTags().contains("育龄妇女")) {
			//判断原来是否存在
			FertileWoman iffertileWoman = fertileWomanService.getBaseMapper().selectOne(new QueryWrapper<>(new FertileWoman()).eq("parent_id", houseUser.getId()));
			if (iffertileWoman == null) {//不存在则新增
				FertileWoman fertileWoman = new FertileWoman();
				fertileWoman.setParentId(houseUser.getId());
				fertileWoman.setName(houseUser.getName());
				fertileWomanService.save(fertileWoman);
			}
		} else {
			//修改时取消了该标签则删除
			FertileWoman iffertileWoman = fertileWomanService.getBaseMapper().selectOne(new QueryWrapper<>(new FertileWoman()).eq("parent_id", houseUser.getId()));
			if (iffertileWoman != null) {//存在则逻辑删除
				fertileWomanService.getBaseMapper().delete(new QueryWrapper<FertileWoman>().eq("parent_id", houseUser.getId()));
			}
		}

		if (houseUser.getTags().contains("刑释人员")) {
			//判断原来是否存在
			Prisoner ifprisoner = prisonerService.getBaseMapper().selectOne(new QueryWrapper<>(new Prisoner()).eq("parent_id", houseUser.getId()));
			if (ifprisoner == null) {//不存在则新增
				Prisoner prisoner = new Prisoner();
				prisoner.setParentId(houseUser.getId());
				prisoner.setName(houseUser.getName());
				prisonerService.save(prisoner);
			}
		} else {
			//修改时取消了该标签则删除
			Prisoner ifprisoner = prisonerService.getBaseMapper().selectOne(new QueryWrapper<>(new Prisoner()).eq("parent_id", houseUser.getId()));
			if (ifprisoner != null) {//存在则逻辑删除
				prisonerService.getBaseMapper().delete(new QueryWrapper<Prisoner>().eq("parent_id", houseUser.getId()));
			}
		}

		if (houseUser.getTags().contains("精神病人")) {
			//判断原来是否存在
			Psychiatric ifpsychiatric = psychiatricService.getBaseMapper().selectOne(new QueryWrapper<>(new Psychiatric()).eq("parent_id", houseUser.getId()));
			if (ifpsychiatric == null) {//不存在则新增
				Psychiatric psychiatric = new Psychiatric();
				psychiatric.setParentId(houseUser.getId());
				psychiatric.setName(houseUser.getName());
				psychiatricService.save(psychiatric);
			}
		} else {
			//修改时取消了该标签则删除
			Psychiatric ifpsychiatric = psychiatricService.getBaseMapper().selectOne(new QueryWrapper<>(new Psychiatric()).eq("parent_id", houseUser.getId()));
			if (ifpsychiatric != null) {//存在则逻辑删除
				psychiatricService.getBaseMapper().delete(new QueryWrapper<Psychiatric>().eq("parent_id", houseUser.getId()));
			}
		}

		if (houseUser.getTags().contains("退伍军人")) {
			//判断原来是否存在
			Veterans ifveterans = veteransService.getBaseMapper().selectOne(new QueryWrapper<>(new Veterans()).eq("parent_id", houseUser.getId()));
			if (ifveterans == null) {//不存在则新增
				Veterans veterans = new Veterans();
				veterans.setParentId(houseUser.getId());
				veterans.setName(houseUser.getName());
				veteransService.save(veterans);
			}
		} else {
			//修改时取消了该标签则删除
			Veterans ifveterans = veteransService.getBaseMapper().selectOne(new QueryWrapper<>(new Veterans()).eq("parent_id", houseUser.getId()));
			if (ifveterans != null) {//存在则逻辑删除
				veteransService.getBaseMapper().delete(new QueryWrapper<Veterans>().eq("parent_id", houseUser.getId()));
			}
		}

		if (houseUser.getTags().contains("艾滋病人")) {
			//判断原来是否存在
			Aids ifaids = aidsService.getBaseMapper().selectOne(new QueryWrapper<>(new Aids()).eq("parent_id", houseUser.getId()));
			if (ifaids == null) {//不存在则新增
				Aids aids = new Aids();
				aids.setParentId(houseUser.getId());
				aids.setName(houseUser.getName());
				aidsService.save(aids);
			}
		} else {
			//修改时取消了该标签则删除
			Aids ifaids = aidsService.getBaseMapper().selectOne(new QueryWrapper<>(new Aids()).eq("parent_id", houseUser.getId()));
			if (ifaids != null) {//存在则逻辑删除
				aidsService.getBaseMapper().delete(new QueryWrapper<Aids>().eq("parent_id", houseUser.getId()));
			}
		}

		if (houseUser.getTags().contains("低保人员")) {
			//判断原来是否存在
			AllowancesPeople ifallowancesPeople = allowancesPeopleService.getBaseMapper().selectOne(new QueryWrapper<>(new AllowancesPeople()).eq("parent_id", houseUser.getId()));
			if (ifallowancesPeople == null) {//不存在则新增
				AllowancesPeople allowancesPeople = new AllowancesPeople();
				allowancesPeople.setParentId(houseUser.getId());
				allowancesPeople.setName(houseUser.getName());
				allowancesPeopleService.save(allowancesPeople);
			}
		} else {
			//修改时取消了该标签则删除
			AllowancesPeople ifallowancesPeople = allowancesPeopleService.getBaseMapper().selectOne(new QueryWrapper<>(new AllowancesPeople()).eq("parent_id", houseUser.getId()));
			if (ifallowancesPeople != null) {//存在则逻辑删除
				allowancesPeopleService.getBaseMapper().delete(new QueryWrapper<AllowancesPeople>().eq("parent_id", houseUser.getId()));
			}
		}
	}

	/**
	 * 处理删除user后，与之关联的会员状态
	 *
	 */
	private boolean dealMemberState(Long userId){
		boolean result = false;
		//查询和user有关系的会员
		ApplyUser condition = new ApplyUser();
		condition.setUserId(userId);
		condition.setAuditStatus(CommonConstant.UserAuditStatus.pass.getValue());
		List<ApplyUserVO> list = this.applyUserClient.list(condition);
		if(list!=null && list.size()>0){
			//删除和user有关系的
			result = this.applyUserClient.remove(list.get(0).getId().toString());
			if(result){
				//修改与之关联的会员状态
				for (ApplyUser mau:list){
					//重新拼凑查询条件，查询与member关联的user个数
					condition.setUserId(null);
					condition.setMemberId(mau.getMemberId());
					condition.setAuditStatus(CommonConstant.UserAuditStatus.pass.getValue());
					//统计
					List<ApplyUserVO> applyUserList = this.applyUserClient.list(condition);
					//会员已经没有了关联的住户，会员状态改为未认证
					if(applyUserList!=null &&applyUserList.size()==0){
						Member update = new Member();
						update.setId(mau.getMemberId());
						//修改会员状态 ----未认证
						update.setState(OperationConstant.ZERO);
						result = this.memberClient.update(update);
					}
				}
			}
		}else {
			result = true;
		}
		return result;
	}

	@Override
	public R pushAddFace(HouseUser houseUser, Map<String, String> extendMap) {
		DispatchTask task = new DispatchTask();
		task.setXqId(houseUser.getResidentialId());
		task.setUnitId(houseUser.getUnitId());
		/**
		 * 待做
		 */
		String confValue = confClient.getValueByToken("file.server.host");
		UserInfoDto userInfoDto = new UserInfoDto();
		userInfoDto.setFaceUrl(houseUser.getFaceUrl());
		userInfoDto.setId(CommonConstant.UserFlag.HOUSE_USER_FLAG.getValue() + houseUser.getId());

		Date begin = new Date();
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Date end = null;
		try{
			end = format.parse("2050-12-31 23:59:59");
		}catch (ParseException e){
			e.printStackTrace();
		}

		userInfoDto.setBeginDate(begin);
		userInfoDto.setEndDate(end);
		userInfoDto.setIdCard(houseUser.getIdCard());
		task.setData(userInfoDto);
		R result = doorDeviceClient.pushUserFace(task, 1);
		if(result.isSuccess()){
			return R.success("人脸下发成功");
		}else{
			return result;
		}
	}

	@Override
	public R pushDelFace(List<HouseUser> userInfoList, Map<String, String> extendMap) {
		for(HouseUser houseUser : userInfoList){
			if(StringUtil.isNotBlank(houseUser.getFaceUrl())){
				UserInfoDto dto = new UserInfoDto();
				dto.setId(CommonConstant.UserFlag.HOUSE_USER_FLAG.getValue() + houseUser.getId());
				dto.setFaceCodeList(new ArrayList<>(0));
				DispatchTask task = new DispatchTask();
				task.setUnitId(houseUser.getUnitId());
				task.setXqId(houseUser.getResidentialId());
				task.setData(dto);
				doorDeviceClient.pushUserFace(task, 2);
			}
		}
		return R.success("删除人脸成功");
	}

	@Override
	public Boolean judgeHaveHouseUser(String idCard, Long roomId){
		QueryWrapper<HouseUser> queryWrapper = new QueryWrapper<>();
		queryWrapper.eq("id_card",idCard);
		queryWrapper.eq("room_id",roomId);
		List<HouseUser> houseUserList = this.list(queryWrapper);
		if (houseUserList.size() > 0){
			return true;
		}else {
			return false;
		}
	}
}
