|
|
@ -1,17 +1,41 @@ |
|
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerIcHouseRedis; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; |
|
|
|
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; |
|
|
|
import com.epmet.commons.tools.redis.common.bean.HouseInfoCache; |
|
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.dao.IcResiUserDao; |
|
|
|
import com.epmet.dao.UserBaseInfoDao; |
|
|
|
import com.epmet.dao.UserResiInfoDao; |
|
|
|
import com.epmet.dao.UserRoleDao; |
|
|
|
import com.epmet.dto.IcHouseDTO; |
|
|
|
import com.epmet.dto.UserResiInfoDTO; |
|
|
|
import com.epmet.dto.form.GetRoleKeyListFormDTO; |
|
|
|
import com.epmet.dto.form.RegisterAndBindFormDTO; |
|
|
|
import com.epmet.dto.result.HomeInfoResultDTO; |
|
|
|
import com.epmet.dto.result.HomeUserBriefResultDTO; |
|
|
|
import com.epmet.feign.GovOrgFeignClient; |
|
|
|
import com.epmet.dto.result.ResiUserBaseInfoResultDTO; |
|
|
|
import com.epmet.entity.IcResiUserEntity; |
|
|
|
import com.epmet.entity.UserBaseInfoEntity; |
|
|
|
import com.epmet.entity.UserResiInfoEntity; |
|
|
|
import com.epmet.feign.GovOrgOpenFeignClient; |
|
|
|
import com.epmet.service.IcResiUserService; |
|
|
|
import com.epmet.service.MyHomeService; |
|
|
|
import com.epmet.service.UserBaseInfoService; |
|
|
|
import com.epmet.service.UserResiInfoService; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.compress.utils.Lists; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
/** |
|
|
@ -25,9 +49,20 @@ public class MyHomeServiceImpl implements MyHomeService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private GovOrgOpenFeignClient govOrgOpenFeignClient; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private IcResiUserService icResiUserService; |
|
|
|
@Resource |
|
|
|
private UserRoleDao userRoleDao; |
|
|
|
@Resource |
|
|
|
private UserResiInfoService userResiInfoService; |
|
|
|
@Resource |
|
|
|
private UserResiInfoDao userResiInfoDao; |
|
|
|
@Resource |
|
|
|
private UserBaseInfoService userBaseInfoService; |
|
|
|
@Resource |
|
|
|
private UserBaseInfoDao userBaseInfoDao; |
|
|
|
@Resource |
|
|
|
private IcResiUserDao icResiUserDao; |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<HomeUserBriefResultDTO> selectListHomeMember(String houseCode, String customerId) { |
|
|
@ -40,4 +75,112 @@ public class MyHomeServiceImpl implements MyHomeService { |
|
|
|
|
|
|
|
return Lists.newArrayList(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 注册绑定房屋信息 |
|
|
|
* |
|
|
|
* @Param formDTO |
|
|
|
* @Return |
|
|
|
* @Author zhaoqifeng |
|
|
|
* @Date 2022/6/1 16:33 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void registerAndBind(RegisterAndBindFormDTO formDTO) { |
|
|
|
//TODO 是否走进入网格(entergrid)流程
|
|
|
|
//1.判断是否是居民,如果不是则注册居民,如果是则更新居民信息
|
|
|
|
GetRoleKeyListFormDTO getRoleKeyListFormDTO = new GetRoleKeyListFormDTO(); |
|
|
|
getRoleKeyListFormDTO.setUserId(formDTO.getUserId()); |
|
|
|
getRoleKeyListFormDTO.setGridId(formDTO.getGridId()); |
|
|
|
List<String> roleList = userRoleDao.selectUserRoleKeyList(getRoleKeyListFormDTO); |
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(roleList) && roleList.contains("registered_resi")) { |
|
|
|
//更新user_resi_info和user_base_info的信息
|
|
|
|
UserResiInfoEntity userResiInfo = new UserResiInfoEntity(); |
|
|
|
userResiInfo.setSurname(formDTO.getSurname()); |
|
|
|
userResiInfo.setName(formDTO.getName()); |
|
|
|
userResiInfo.setIdNum(formDTO.getIdCard()); |
|
|
|
userResiInfo.setRegMobile(formDTO.getMobile()); |
|
|
|
userResiInfo.setResiVisitId(formDTO.getVisitId()); |
|
|
|
userResiInfo.setDistrict(formDTO.getAddress()); |
|
|
|
|
|
|
|
LambdaQueryWrapper<UserResiInfoEntity> wrapper = new LambdaQueryWrapper<>(); |
|
|
|
wrapper.eq(UserResiInfoEntity::getCustomerId, formDTO.getCustomerId()); |
|
|
|
wrapper.eq(UserResiInfoEntity::getUserId, formDTO.getUserId()); |
|
|
|
userResiInfoDao.update(userResiInfo, wrapper); |
|
|
|
|
|
|
|
UserBaseInfoEntity userBaseInfoEntity = ConvertUtils.sourceToTarget(userResiInfo, UserBaseInfoEntity.class); |
|
|
|
userBaseInfoService.insertOrUpdate(userBaseInfoEntity); |
|
|
|
} else { |
|
|
|
//注册居民
|
|
|
|
UserResiInfoDTO userResiInfoDTO = ConvertUtils.sourceToTarget(formDTO, UserResiInfoDTO.class); |
|
|
|
userResiInfoDTO.setIdNum(formDTO.getIdCard()); |
|
|
|
userResiInfoDTO.setRegMobile(formDTO.getMobile()); |
|
|
|
userResiInfoDTO.setResiVisitId(formDTO.getVisitId()); |
|
|
|
userResiInfoDTO.setDistrict(formDTO.getAddress()); |
|
|
|
userResiInfoDTO.setCustomerId(formDTO.getCustomerId()); |
|
|
|
userResiInfoDTO.setApp("resi"); |
|
|
|
userResiInfoService.saveResiInfo(userResiInfoDTO); |
|
|
|
} |
|
|
|
//2.添加ic_resi_user信息
|
|
|
|
LambdaQueryWrapper<IcResiUserEntity> wrapper = new LambdaQueryWrapper<>(); |
|
|
|
wrapper.eq(IcResiUserEntity::getCustomerId, formDTO.getCustomerId()); |
|
|
|
wrapper.eq(IcResiUserEntity::getIdCard, formDTO.getIdCard()); |
|
|
|
IcResiUserEntity icUser = icResiUserDao.selectOne(wrapper); |
|
|
|
|
|
|
|
HouseInfoCache houseInfo = CustomerIcHouseRedis.getHouseInfo(formDTO.getCustomerId(), formDTO.getHomeId()); |
|
|
|
if (null == houseInfo) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取房屋信息失败", "获取房屋信息失败"); |
|
|
|
} |
|
|
|
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(houseInfo.getAgencyId()); |
|
|
|
if (null == agencyInfo) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取组织信息失败", "获取组织信息失败"); |
|
|
|
} |
|
|
|
IcResiUserEntity icUserEntity = ConvertUtils.sourceToTarget(formDTO, IcResiUserEntity.class); |
|
|
|
icUserEntity.setName(formDTO.getSurname() + formDTO.getName()); |
|
|
|
icUserEntity.setAgencyId(houseInfo.getAgencyId()); |
|
|
|
icUserEntity.setPids(agencyInfo.getPids()); |
|
|
|
if (null != icUser) { |
|
|
|
icUserEntity.setId(icUser.getId()); |
|
|
|
icResiUserDao.updateById(icUserEntity); |
|
|
|
} else { |
|
|
|
icResiUserDao.insert(icUserEntity); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取用户绑定的房屋信息 |
|
|
|
* |
|
|
|
* @param tokenDto |
|
|
|
* @Param tokenDto |
|
|
|
* @Return {@link HomeInfoResultDTO} |
|
|
|
* @Author zhaoqifeng |
|
|
|
* @Date 2022/6/1 16:52 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public HomeInfoResultDTO getHomeInfo(TokenDto tokenDto) { |
|
|
|
HomeInfoResultDTO resultDto = new HomeInfoResultDTO(); |
|
|
|
ResiUserBaseInfoResultDTO baseInfo = userBaseInfoDao.selecUserBaseInfoByUserId(tokenDto.getUserId()); |
|
|
|
if (null == baseInfo) { |
|
|
|
return resultDto; |
|
|
|
} |
|
|
|
|
|
|
|
LambdaQueryWrapper<IcResiUserEntity> wrapper = new LambdaQueryWrapper<>(); |
|
|
|
wrapper.eq(IcResiUserEntity::getCustomerId, tokenDto.getCustomerId()); |
|
|
|
wrapper.eq(IcResiUserEntity::getIdCard, baseInfo.getIdNum()); |
|
|
|
IcResiUserEntity icUser = icResiUserDao.selectOne(wrapper); |
|
|
|
|
|
|
|
if (null == icUser) { |
|
|
|
return resultDto; |
|
|
|
} |
|
|
|
resultDto.setIcResiUserId(icUser.getId()); |
|
|
|
//TODO 获取房屋信息
|
|
|
|
HouseInfoCache houseInfo = CustomerIcHouseRedis.getHouseInfo(tokenDto.getCustomerId(), icUser.getHomeId()); |
|
|
|
if (null == houseInfo) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取房屋信息失败", "获取房屋信息失败"); |
|
|
|
} |
|
|
|
resultDto.setHouseName(houseInfo.getAllName()); |
|
|
|
resultDto.setHouseCode(null); |
|
|
|
resultDto.setQrCodeUrl(null); |
|
|
|
return resultDto; |
|
|
|
} |
|
|
|
} |
|
|
|