diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/HouseInfoFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/HouseInfoFormDTO.java index e1dd0ea53d..0d220b193d 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/HouseInfoFormDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/HouseInfoFormDTO.java @@ -16,4 +16,5 @@ public class HouseInfoFormDTO implements Serializable { @NotNull(message = "房屋编码不可为空") private String houseCode; + private String userId; } diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcHouseInfoFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcHouseInfoFormDTO.java index adde362546..3df20aa3b2 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcHouseInfoFormDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcHouseInfoFormDTO.java @@ -22,5 +22,5 @@ public class IcHouseInfoFormDTO extends PageFormDTO { private String houseCode; private String customerId; - + private String userId; } diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/HouseInfoResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/HouseInfoResultDTO.java index ddb4af560e..e827b468ef 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/HouseInfoResultDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/HouseInfoResultDTO.java @@ -108,4 +108,8 @@ public class HouseInfoResultDTO implements Serializable { * 房屋可编辑编码 */ private String coding; + /** + * 是否是房主 + */ + private String isOwner = "0"; } diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcHouseInfoResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcHouseInfoResultDTO.java index d958f1494b..c3c77e446f 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcHouseInfoResultDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcHouseInfoResultDTO.java @@ -59,7 +59,16 @@ public class IcHouseInfoResultDTO implements Serializable { * 客户id */ private String customerId; + private String isOwner = "0"; + private String ownerIdCard; + /** + * 房屋编码 + */ + private String houseCode; + /** + * 二维码地址 + */ + private String qrCodeUrl; - - + private String coding; } diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java index b7c17a255d..7e2bcae37e 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java @@ -695,4 +695,14 @@ public interface GovOrgOpenFeignClient { */ @PostMapping("/gov/org/coverage/dictinit/{customerId}") Result dictInit(@PathVariable(value = "customerId") String customerId); + + /** + * 获取房主名下的房屋 + * @Param formDTO + * @Return {@link Result< List>} + * @Author zhaoqifeng + * @Date 2022/7/20 9:52 + */ + @PostMapping("/gov/org/ichouse/getOwnerHouseList") + Result> getOwnerHouseList(@RequestBody IcHouseDTO formDTO); } diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java index 0a8e690f38..f9046d5979 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java @@ -445,4 +445,18 @@ public class GovOrgOpenFeignClientFallback implements GovOrgOpenFeignClient { return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "dictInit", customerId); } + /** + * 获取房主名下的房屋 + * + * @param formDTO + * @Param formDTO + * @Return {@link Result< List>} + * @Author zhaoqifeng + * @Date 2022/7/20 9:52 + */ + @Override + public Result> getOwnerHouseList(IcHouseDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getOwnerHouseList", formDTO); + } + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java index bd04087da4..62dfafccdf 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java @@ -516,6 +516,7 @@ public class HouseController implements ResultDataResolver { //效验数据 ValidatorUtils.validateEntity(formDTO); formDTO.setCustomerId(loginUser.getCustomerId()); + formDTO.setUserId(loginUser.getUserId()); return houseService.getHouseInfoByCode(formDTO); } @@ -569,7 +570,8 @@ public class HouseController implements ResultDataResolver { * @return com.epmet.commons.tools.utils.Result */ @PostMapping("getHomeInfoByHouseCode") - public Result getHomeInfoByHouseCode(@RequestBody HouseInfoFormDTO dto) { + public Result getHomeInfoByHouseCode(@LoginUser TokenDto tokenDto, @RequestBody HouseInfoFormDTO dto) { + dto.setUserId(tokenDto.getUserId()); //效验数据 ValidatorUtils.validateEntity(dto); return houseService.getHomeInfoByHouseCode(dto); diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcHouseController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcHouseController.java index 63668ceba1..49e3f15f92 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcHouseController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcHouseController.java @@ -24,6 +24,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.dto.IcHouseDTO; import com.epmet.dto.form.HouseFormDTO; import com.epmet.dto.result.HouseAgencyInfoResultDTO; +import com.epmet.dto.result.HouseInfoDTO; import com.epmet.dto.result.HouseListResultDTO; import com.epmet.dto.result.HousesNameResultDTO; import com.epmet.service.IcHouseService; @@ -121,4 +122,18 @@ public class IcHouseController { public Result updateIcHouseResiNumber(@RequestBody List> paramList){ return new Result().ok(icHouseService.updateIcHouseResiNumber(paramList)); } + + + /** + * 获取房主名下的房屋 + * + * @Param idCards + * @Return {@link Result< List< HouseInfoDTO>>} + * @Author zhaoqifeng + * @Date 2022/7/19 17:39 + */ + @PostMapping("getOwnerHouseList") + public Result> getOwnerHouseList(@RequestBody IcHouseDTO formDTO){ + return new Result>().ok(icHouseService.getOwnerHouseList(formDTO)); + } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcHouseService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcHouseService.java index 9aa68a4047..522acba117 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcHouseService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcHouseService.java @@ -7,6 +7,7 @@ import com.epmet.dto.IcHouseDTO; import com.epmet.dto.ImportGeneralDTO; import com.epmet.dto.form.HouseFormDTO; import com.epmet.dto.result.HouseAgencyInfoResultDTO; +import com.epmet.dto.result.HouseInfoDTO; import com.epmet.dto.result.HouseListResultDTO; import com.epmet.dto.result.HousesNameResultDTO; import com.epmet.entity.IcHouseEntity; @@ -119,4 +120,14 @@ public interface IcHouseService extends BaseService { * @return */ Integer updateIcHouseResiNumber(List> paramList); + + /** + * 获取房主名下的房屋 + * + * @Param formDTO + * @Return {@link List< HouseInfoDTO>} + * @Author zhaoqifeng + * @Date 2022/7/19 17:41 + */ + List getOwnerHouseList(IcHouseDTO formDTO); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java index 015506055a..5d0556337b 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java @@ -20,10 +20,12 @@ import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.redis.common.CustomerIcHouseRedis; import com.epmet.commons.tools.redis.common.CustomerOrgRedis; +import com.epmet.commons.tools.redis.common.CustomerResiUserRedis; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; import com.epmet.commons.tools.redis.common.bean.GridInfoCache; import com.epmet.commons.tools.redis.common.bean.HouseInfoCache; +import com.epmet.commons.tools.redis.common.bean.ResiUserInfoCache; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.*; import com.epmet.constant.CustomerGridConstant; @@ -1058,9 +1060,23 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "未查询到相关房屋","未查询到相关房屋"); } HouseInfoCache cache = CustomerIcHouseRedis.getHouseInfo(formDTO.getCustomerId(), house.getId()); - IcHouseInfoResultDTO resut = ConvertUtils.sourceToTarget(cache, IcHouseInfoResultDTO.class); - resut.setHouseId(cache.getHomeId()); - return new Result().ok(resut); + if (null == cache) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "未查询到相关房屋","未查询到相关房屋"); + } + IcHouseInfoResultDTO result = ConvertUtils.sourceToTarget(cache, IcHouseInfoResultDTO.class); + result.setHouseId(cache.getHomeId()); + result.setOwnerIdCard(house.getOwnerIdCard()); + result.setCoding(house.getCoding()); + result.setHouseName(cache.getAllName()); + result.setQrCodeUrl(house.getHouseQrcodeUrl()); + ResiUserInfoCache userInfo = CustomerResiUserRedis.getUserBaseInfo(formDTO.getUserId()); + if (null != userInfo) { + if (StringUtils.equals(house.getOwnerIdCard(), userInfo.getIdNum())) { + result.setIsOwner(NumConstant.ONE_STR); + + } + } + return new Result().ok(result); } @@ -1137,6 +1153,12 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { house.setHouseTypeName(HouseTypeEnums.getTypeValue(house.getHouseType())); house.setRentName(HouseRentFlagEnums.getTypeValue(house.getRentFlag())); house.setPurposeName(HousePurposeEnums.getTypeValue(house.getPurpose())); + ResiUserInfoCache userInfo = CustomerResiUserRedis.getUserBaseInfo(dto.getUserId()); + if (null != userInfo) { + if (StringUtils.equals(house.getOwnerIdCard(), userInfo.getIdNum())) { + house.setIsOwner(NumConstant.ONE_STR); + } + } return new Result().ok(house); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcHouseServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcHouseServiceImpl.java index 98e340221c..d93d589134 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcHouseServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcHouseServiceImpl.java @@ -22,6 +22,7 @@ import com.epmet.dto.IcResiUserDTO; import com.epmet.dto.ImportGeneralDTO; import com.epmet.dto.form.HouseFormDTO; import com.epmet.dto.result.HouseAgencyInfoResultDTO; +import com.epmet.dto.result.HomeInfoResultDTO; import com.epmet.dto.result.HouseInfoDTO; import com.epmet.dto.result.HouseListResultDTO; import com.epmet.dto.result.HousesNameResultDTO; @@ -310,4 +311,26 @@ public class IcHouseServiceImpl extends BaseServiceImpl} + * @Author zhaoqifeng + * @Date 2022/7/19 17:41 + */ + @Override + public List getOwnerHouseList(IcHouseDTO formDTO) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(IcHouseEntity::getCustomerId, formDTO.getCustomerId()); + wrapper.eq(IcHouseEntity::getOwnerIdCard, formDTO.getOwnerIdCard()); + wrapper.ne(IcHouseEntity::getHouseCode, formDTO.getHouseCode()); + List list = baseDao.selectList(wrapper); + if (CollectionUtils.isEmpty(list)) { + return Collections.emptyList(); + } + return list.stream().map(item -> icHouseRedis.getHouseInfo(item.getId(), item.getCustomerId())).collect(Collectors.toList()); + } } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcResiUserConfirmSubmitDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcResiUserConfirmSubmitDTO.java index ea119fbd80..e2bbad8810 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcResiUserConfirmSubmitDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcResiUserConfirmSubmitDTO.java @@ -210,5 +210,5 @@ public class IcResiUserConfirmSubmitDTO implements Serializable { private String operationDescribe; private String houseCode; - + private Boolean isOwner = false; } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/HomeInfoResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/HomeInfoResultDTO.java index 9572068118..18a790d63a 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/HomeInfoResultDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/HomeInfoResultDTO.java @@ -21,4 +21,12 @@ public class HomeInfoResultDTO implements Serializable { private String houseCode; private String coding; private String qrCodeUrl; + /** + * 是否是房主 + */ + private String isOwner = "0"; + /** + * 房主身份证 + */ + private String ownerIdCard; } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/RegisterAndBindResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/RegisterAndBindResultDTO.java new file mode 100644 index 0000000000..cb30766181 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/RegisterAndBindResultDTO.java @@ -0,0 +1,17 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description + * @Author zhaoqifeng + * @Date 2022/7/20 17:13 + */ +@Data +public class RegisterAndBindResultDTO implements Serializable { + private static final long serialVersionUID = 718455504517985543L; + private String isOwner = "0"; + private String isDiff = "0"; +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/MyHomeController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/MyHomeController.java index a622798520..a2d754b2e9 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/MyHomeController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/MyHomeController.java @@ -10,12 +10,10 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.dto.IcHouseDTO; import com.epmet.dto.IcResiUserConfirmDTO; import com.epmet.dto.form.*; -import com.epmet.dto.result.ConfirmListResultDTO; -import com.epmet.dto.result.HomeInfoResultDTO; -import com.epmet.dto.result.HomeUserBriefResultDTO; -import com.epmet.dto.result.MoveOutDetailResultDTO; +import com.epmet.dto.result.*; import com.epmet.service.IcResiUserConfirmService; import com.epmet.service.IcResiUserService; import com.epmet.service.MyHomeService; @@ -135,11 +133,10 @@ public class MyHomeController { * @Date 2022/6/1 10:26 */ @PostMapping("registerAndBind") - public Result registerAndBind(@LoginUser TokenDto tokenDto, @RequestBody RegisterAndBindFormDTO formDTO) { + public Result registerAndBind(@LoginUser TokenDto tokenDto, @RequestBody RegisterAndBindFormDTO formDTO) { formDTO.setCustomerId(tokenDto.getCustomerId()); formDTO.setUserId(tokenDto.getUserId()); - myHomeService.registerAndBind(formDTO); - return new Result(); + return new Result().ok(myHomeService.registerAndBind(formDTO)); } @PostMapping("homeInfo") @@ -200,4 +197,33 @@ public class MyHomeController { return new Result(); } + /** + * 获取房主名下的房屋列表 + * + * @Param tokenDto + * @Return {@link Result< HomeInfoResultDTO>} + * @Author zhaoqifeng + * @Date 2022/7/19 16:46 + */ + @PostMapping("getOwnerHouseList") + public Result> getOwnerHouseList(@LoginUser TokenDto tokenDto, @RequestBody IcHouseDTO formDTO) { + List result = myHomeService.getOwnerHouseList(tokenDto, formDTO); + return new Result>().ok(result); + } + + /** + * 变更绑定的房屋 + * + * @Param tokenDto + * @Param formDTO + * @Return {@link Result} + * @Author zhaoqifeng + * @Date 2022/7/20 17:28 + */ + @PostMapping("changeHome") + public Result changeHome(@LoginUser TokenDto tokenDto, @RequestBody IcResiUserConfirmSubmitDTO formDTO) { + myHomeService.changeHome(tokenDto, formDTO); + return new Result(); + } + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/MyHomeService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/MyHomeService.java index 0d1667b03d..a4f140670f 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/MyHomeService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/MyHomeService.java @@ -1,9 +1,12 @@ package com.epmet.service; import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.dto.IcHouseDTO; +import com.epmet.dto.form.IcResiUserConfirmSubmitDTO; import com.epmet.dto.form.RegisterAndBindFormDTO; import com.epmet.dto.result.HomeInfoResultDTO; import com.epmet.dto.result.HomeUserBriefResultDTO; +import com.epmet.dto.result.RegisterAndBindResultDTO; import java.util.List; @@ -21,7 +24,7 @@ public interface MyHomeService { * @Author zhaoqifeng * @Date 2022/6/1 16:33 */ - void registerAndBind(RegisterAndBindFormDTO formDTO); + RegisterAndBindResultDTO registerAndBind(RegisterAndBindFormDTO formDTO); /** * 获取用户绑定的房屋信息 @@ -43,4 +46,25 @@ public interface MyHomeService { * @date 2022/6/1/0001 16:12 */ List selectListHomeMember(String houseCode, String customerId); + + /** + * 获取房主名下的房屋列表 + * + * @Param tokenDto + * @Return {@link List< HomeInfoResultDTO>} + * @Author zhaoqifeng + * @Date 2022/7/19 16:48 + */ + List getOwnerHouseList(TokenDto tokenDto, IcHouseDTO formDTO); + + /** + * 变更绑定的房屋 + * + * @Param tokenDto + * @Param formDTO + * @Return + * @Author zhaoqifeng + * @Date 2022/7/20 17:28 + */ + void changeHome(TokenDto tokenDto, IcResiUserConfirmSubmitDTO formDTO); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java index 979da210ff..57fd9c7d34 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java @@ -41,10 +41,12 @@ import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.redis.common.CustomerIcHouseRedis; import com.epmet.commons.tools.redis.common.CustomerOrgRedis; +import com.epmet.commons.tools.redis.common.CustomerResiUserRedis; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; import com.epmet.commons.tools.redis.common.bean.GridInfoCache; import com.epmet.commons.tools.redis.common.bean.HouseInfoCache; +import com.epmet.commons.tools.redis.common.bean.ResiUserInfoCache; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.*; import com.epmet.constant.IcPlatformConstant; @@ -2416,17 +2418,83 @@ public class IcResiUserServiceImpl extends BaseServiceImpl icHouseNewResult = govOrgOpenFeignClient.get(dto.getHomeId()); + if (!icHouseNewResult.success() || null == icHouseNewResult.getData()) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取房屋信息失败", "获取房屋信息失败"); + } + + HouseInfoCache houseInfo = CustomerIcHouseRedis.getHouseInfo(tokenDto.getCustomerId(), dto.getHomeId()); + if (null == houseInfo) { + String errorMsg = "获取房屋信息失败"; + throw new EpmetException(EpmetErrorCode.ORG_ADD_FAILED.getCode(), errorMsg, errorMsg); + } + GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(houseInfo.getGridId()); + if (null == gridInfo) { + String errorMsg = "获取网格信息失败"; + throw new EpmetException(EpmetErrorCode.ORG_ADD_FAILED.getCode(), errorMsg, errorMsg); + } + + dto.setCustomerId(tokenDto.getCustomerId()); + dto.setAgencyId(houseInfo.getAgencyId()); + dto.setPids(gridInfo.getPids()); + dto.setGridId(houseInfo.getGridId()); + dto.setVillageId(houseInfo.getNeighborHoodId()); + dto.setBuildId(houseInfo.getBuildingId()); + dto.setUnitId(houseInfo.getBuildingUnitId()); + dto.setHomeId(dto.getHomeId()); + dto.setStaffId(tokenDto.getUserId()); + if (idCard.equals(icHouseNewResult.getData().getOwnerIdCard())) { + dto.setIsOwner(true); + } - IcResiUserDTO userDTO = baseDao.getResiUserByIdCard(dto.getIdCard(), user.getCustomerId()); if (null != userDTO && null != userDTO.getIdCard()) { - String errorMsg = "新增居民信息失败,身份证号已存在!"; - throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), errorMsg, errorMsg); + if (dto.getIsOwner()) { + //如果是房东,可以将其名下其他房屋的人员移到当前房屋 + if (dto.getHomeId().equals(userDTO.getHomeId())) { + String errorMsg = "新增居民信息失败,身份证号已存在!"; + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), errorMsg, errorMsg); + } else { + //判断房屋的房主是否同一人 + Result icHouseResult = govOrgOpenFeignClient.get(userDTO.getHomeId()); + if (!icHouseResult.success() || null == icHouseResult.getData()) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取房屋信息失败", "获取房屋信息失败"); + } + if (StringUtils.equals(icHouseResult.getData().getOwnerIdCard(), icHouseNewResult.getData().getOwnerIdCard())) { + //走迁移逻辑 + //这个房屋下已经设置了户主后,再次选择户主时提示提示“房屋下已存在户主” PS.户主指与户主关系是本人的用户 + if (RelationshipEnum.SELF.getCode().equals(dto.getYhzgx())) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(IcResiUserEntity::getHomeId, dto.getHomeId()); + wrapper.eq(IcResiUserEntity::getYhzgx, RelationshipEnum.SELF.getCode()); + List entityList = baseDao.selectList(wrapper); + if (CollectionUtils.isNotEmpty(entityList)) { + String errorMsg = "房屋下已存在户主"; + throw new EpmetException(EpmetErrorCode.ORG_ADD_FAILED.getCode(), errorMsg, errorMsg); + } + } + return updateOldMemberInfo(tokenDto.getCustomerId(),dto); + } else { + String errorMsg = "您无权操作其他家庭的成员,如有问题请联系工作人员"; + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), errorMsg, errorMsg); + } + } + } else { + String errorMsg = "新增居民信息失败,身份证号已存在!"; + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), errorMsg, errorMsg); + } } //这个房屋下已经设置了户主后,再次选择户主时提示提示“房屋下已存在户主” PS.户主指与户主关系是本人的用户 if (RelationshipEnum.SELF.getCode().equals(dto.getYhzgx())) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(IcResiUserEntity::getHomeId, user.getHomeId()); + wrapper.eq(IcResiUserEntity::getHomeId, dto.getHomeId()); wrapper.eq(IcResiUserEntity::getYhzgx, RelationshipEnum.SELF.getCode()); List entityList = baseDao.selectList(wrapper); if (CollectionUtils.isNotEmpty(entityList)) { @@ -2436,15 +2504,6 @@ public class IcResiUserServiceImpl extends BaseServiceImpl selectListHomeMember(String houseCode, String customerId) { @@ -86,18 +93,42 @@ public class MyHomeServiceImpl implements MyHomeService { */ @Override @Transactional(rollbackFor = Exception.class) - public void registerAndBind(RegisterAndBindFormDTO formDTO) { - + public RegisterAndBindResultDTO registerAndBind(RegisterAndBindFormDTO formDTO) { + RegisterAndBindResultDTO result = new RegisterAndBindResultDTO(); LambdaQueryWrapper userWrapper = new LambdaQueryWrapper<>(); userWrapper.eq(IcResiUserEntity::getCustomerId, formDTO.getCustomerId()); userWrapper.eq(IcResiUserEntity::getIdCard, formDTO.getIdCard()); IcResiUserEntity icUser = icResiUserDao.selectOne(userWrapper); - if (null == icUser || !icUser.getHomeId().equals(formDTO.getHomeId())) { + //获取用户扫码的房屋 + Result icHouseNewResult = govOrgOpenFeignClient.get(formDTO.getHomeId()); + if (!icHouseNewResult.success() || null == icHouseNewResult.getData()) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取房屋信息失败", "获取房屋信息失败"); + } + if (formDTO.getIdCard().equals(icHouseNewResult.getData().getOwnerIdCard())) { + //判断是否是房主 + result.setIsOwner(NumConstant.ONE_STR); + } + if (null == icUser) { throw new EpmetException(EpmetErrorCode.MISMATCH.getCode(), "人员与房屋信息不匹配,请与工作人员联系。", "人员与房屋信息不匹配,请与工作人员联系。"); + } else if (!icUser.getHomeId().equals(formDTO.getHomeId())) { + //获取用户当前所在的房屋 + Result icHouseResult = govOrgOpenFeignClient.get(icUser.getHomeId()); + if (!icHouseResult.success() || null == icHouseResult.getData()) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取房屋信息失败", "获取房屋信息失败"); + } + //判断两个房屋是否是一个房主 + if (!StringUtils.equals(icHouseResult.getData().getOwnerIdCard(), icHouseNewResult.getData().getOwnerIdCard())) { + throw new EpmetException(EpmetErrorCode.MISMATCH.getCode(), + "人员与房屋信息不匹配,请与工作人员联系。", + "人员与房屋信息不匹配,请与工作人员联系。"); + } else { + result.setIsDiff(NumConstant.ONE_STR); + } } + //进入网格(entergrid)流程 EnterGridFormDTO userInfoParams = new EnterGridFormDTO(); userInfoParams.setUserId(formDTO.getUserId()); @@ -151,6 +182,7 @@ public class MyHomeServiceImpl implements MyHomeService { userResiInfoDTO.setApp("resi"); userResiInfoService.saveResiInfo(userResiInfoDTO); } + return result; } /** @@ -165,20 +197,21 @@ public class MyHomeServiceImpl implements MyHomeService { @Override public HomeInfoResultDTO getHomeInfo(TokenDto tokenDto) { HomeInfoResultDTO resultDto = new HomeInfoResultDTO(); + //通过用户ID获取居民端用户信息 ResiUserBaseInfoResultDTO baseInfo = userBaseInfoDao.selecUserBaseInfoByUserId(tokenDto.getUserId()); if (null == baseInfo) { return resultDto; } - + //通过居民身份证号获取居民信息 LambdaQueryWrapper 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()); + //通过房屋ID获取房屋信息 HouseInfoCache houseInfo = CustomerIcHouseRedis.getHouseInfo(tokenDto.getCustomerId(), icUser.getHomeId()); if (null == houseInfo) { throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取房屋信息失败", "获取房屋信息失败"); @@ -188,6 +221,123 @@ public class MyHomeServiceImpl implements MyHomeService { resultDto.setHouseCode(houseInfo.getHouseCode()); resultDto.setQrCodeUrl(houseInfo.getHouseQrcodeUrl()); resultDto.setCoding(houseInfo.getCoding()); + //获取房屋房主信息,判断是否是房主 + Result icHouseResult = govOrgOpenFeignClient.get(icUser.getHomeId()); + if (!icHouseResult.success() || null == icHouseResult.getData()) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取房屋信息失败", "获取房屋信息失败"); + } + if (icUser.getIdCard().equals(icHouseResult.getData().getOwnerIdCard())) { + resultDto.setIsOwner(NumConstant.ONE_STR); + } else { + resultDto.setIsOwner(NumConstant.ZERO_STR); + } + resultDto.setOwnerIdCard(icHouseResult.getData().getOwnerIdCard()); return resultDto; } + + /** + * 获取房主名下的房屋列表 + * + * @param tokenDto + * @Param tokenDto + * @Return {@link List< HomeInfoResultDTO>} + * @Author zhaoqifeng + * @Date 2022/7/19 16:48 + */ + @Override + public List getOwnerHouseList(TokenDto tokenDto, IcHouseDTO formDTO) { + //通过用户ID获取居民端用户信息 + ResiUserBaseInfoResultDTO baseInfo = userBaseInfoDao.selecUserBaseInfoByUserId(tokenDto.getUserId()); + if (null == baseInfo) { + return Collections.emptyList(); + } + + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setOwnerIdCard(baseInfo.getIdNum()); + Result> houseResult = govOrgOpenFeignClient.getOwnerHouseList(formDTO); + if (!houseResult.success()) { + throw new EpmetException(houseResult.getCode(), houseResult.getMsg()); + } + if (CollectionUtils.isEmpty(houseResult.getData())) { + return Collections.emptyList(); + } + List list = houseResult.getData().stream().map(item -> { + HomeInfoResultDTO result = new HomeInfoResultDTO(); + result.setHouseId(item.getHomeId()); + result.setHouseName(item.getAllName()); + result.setHouseCode(item.getHouseCode()); + result.setQrCodeUrl(item.getHouseQrcodeUrl()); + return result; + }).collect(Collectors.toList()); + return list.stream().sorted((o1, o2) -> + Collator.getInstance(Locale.SIMPLIFIED_CHINESE) + .compare(o1.getHouseName(),o2.getHouseName())).collect(Collectors.toList()); + } + + /** + * 变更绑定的房屋 + * + * @param tokenDto + * @param formDTO + * @Param tokenDto + * @Param formDTO + * @Return {@link List< HomeInfoResultDTO>} + * @Author zhaoqifeng + * @Date 2022/7/20 17:25 + */ + @Override + public void changeHome(TokenDto tokenDto, IcResiUserConfirmSubmitDTO formDTO) { + //通过用户ID获取居民端用户信息 + ResiUserBaseInfoResultDTO baseInfo = userBaseInfoDao.selecUserBaseInfoByUserId(tokenDto.getUserId()); + if (null == baseInfo) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取用户信息失败", "获取用户信息失败"); + } + //通过居民身份证号获取居民信息 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(IcResiUserEntity::getCustomerId, tokenDto.getCustomerId()); + wrapper.eq(IcResiUserEntity::getIdCard, baseInfo.getIdNum()); + IcResiUserEntity icUser = icResiUserDao.selectOne(wrapper); + if (null == icUser) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取居民信息失败", "获取居民信息失败"); + } + + //通过房屋ID获取房屋信息 + HouseInfoCache houseInfo = CustomerIcHouseRedis.getHouseInfo(tokenDto.getCustomerId(), formDTO.getHomeId()); + if (null == houseInfo) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取房屋信息失败", "获取房屋信息失败"); + } + GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(houseInfo.getGridId()); + if (null == gridInfo) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取网格信息失败", "获取网格信息失败"); + } + //在添加调动记录的时候调整 + icUser.setAgencyId(houseInfo.getAgencyId()); + icUser.setPids(gridInfo.getPids()); + icUser.setGridId(houseInfo.getGridId()); + icUser.setVillageId(houseInfo.getNeighborHoodId()); + icUser.setBuildId(houseInfo.getBuildingId()); + icUser.setUnitId(houseInfo.getBuildingUnitId()); + icUser.setHomeId(houseInfo.getHomeId()); + icUser.setUpdatedTime(new java.util.Date()); + + //添加人员调动记录 + IcResiUserTransferFormDTO transferDTO = new IcResiUserTransferFormDTO(); + transferDTO.setCustomerId(tokenDto.getCustomerId()); + transferDTO.setStaffId(tokenDto.getUserId()); + transferDTO.setIcUserId(icUser.getId()); + transferDTO.setType("in"); + transferDTO.setNewAgencyId(houseInfo.getAgencyId()); + transferDTO.setNewGridId(houseInfo.getGridId()); + transferDTO.setNewNeighborHoodId(houseInfo.getNeighborHoodId()); + transferDTO.setNewBuildingId(houseInfo.getBuildingId()); + transferDTO.setNewBuildingUnitId(houseInfo.getBuildingUnitId()); + transferDTO.setNewHouseId(houseInfo.getHomeId()); + transferDTO.setTransferTime(new java.util.Date()); + transferDTO.setRemark("更换房屋"); + transferDTO.setReason("更换房屋"); + transferDTO.setOrigin(IcResiUserConstant.CHANGE); + icUserTransferRecordService.add(transferDTO); + //更新家庭成员信息 + icResiUserDao.updateById(icUser); + } } diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml index 95213638e2..c00d257ae4 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml @@ -445,7 +445,8 @@ id_card, mobile, agency_id, - grid_id + grid_id, + home_id FROM ic_resi_user WHERE