diff --git a/epmet-auth/src/main/java/com/epmet/controller/ThirdLoginController.java b/epmet-auth/src/main/java/com/epmet/controller/ThirdLoginController.java index a4f0ba4413..5244b9610e 100644 --- a/epmet-auth/src/main/java/com/epmet/controller/ThirdLoginController.java +++ b/epmet-auth/src/main/java/com/epmet/controller/ThirdLoginController.java @@ -4,6 +4,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.form.*; import com.epmet.dto.result.ResiDingAppLoginResDTO; +import com.epmet.dto.result.ResiRegisterLantuResultDTO; import com.epmet.dto.result.StaffOrgsResultDTO; import com.epmet.dto.result.UserTokenResultDTO; import com.epmet.service.ThirdLoginService; @@ -219,6 +220,19 @@ public class ThirdLoginController { return new Result().ok(thirdLoginService.resiLoginHfive(formDTO)); } + /** + * @Description: 蓝图 居民注册 + * @param formDTO: + * @Return com.epmet.commons.tools.utils.Result + * @Author: lichao + * @Date: 2023/8/16 10:13 + */ + @PostMapping("resiRegister-lantu") + public Result resiRegisterLantu(@RequestBody ResiRegisterLantuFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + return new Result().ok(thirdLoginService.resiRegisterLantu(formDTO)); + } + /** * 根据免登授权码, 获取登录用户身份 * diff --git a/epmet-auth/src/main/java/com/epmet/dto/form/ResiRegisterLantuFormDTO.java b/epmet-auth/src/main/java/com/epmet/dto/form/ResiRegisterLantuFormDTO.java new file mode 100644 index 0000000000..fb42d6c766 --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/dto/form/ResiRegisterLantuFormDTO.java @@ -0,0 +1,30 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * @Description: 蓝图 注册居民入参 + * @Author: lichao + * @Date: 2023/8/15 09:25 + */ +@Data +public class ResiRegisterLantuFormDTO { + + + @NotBlank(message = "phone不能为空") + private String phone; + + @NotBlank(message = "nick不能为空") + private String nick; + + @NotBlank(message = "gridId不能为空") + private String gridId; + + private String avatarUrl; + + + +} + diff --git a/epmet-auth/src/main/java/com/epmet/dto/result/ResiRegisterLantuResultDTO.java b/epmet-auth/src/main/java/com/epmet/dto/result/ResiRegisterLantuResultDTO.java new file mode 100644 index 0000000000..ee04257e18 --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/dto/result/ResiRegisterLantuResultDTO.java @@ -0,0 +1,16 @@ +package com.epmet.dto.result; + +import lombok.Data; + +/** + * @Description: lantu 结果 + * @Author: lichao + * @Date: 2023/8/16 10:11 + */ +@Data +public class ResiRegisterLantuResultDTO { + + private String id; + +} + diff --git a/epmet-auth/src/main/java/com/epmet/service/ThirdLoginService.java b/epmet-auth/src/main/java/com/epmet/service/ThirdLoginService.java index e0cdbf52c2..9e6d51596e 100644 --- a/epmet-auth/src/main/java/com/epmet/service/ThirdLoginService.java +++ b/epmet-auth/src/main/java/com/epmet/service/ThirdLoginService.java @@ -2,6 +2,7 @@ package com.epmet.service; import com.epmet.dto.form.*; import com.epmet.dto.result.ResiDingAppLoginResDTO; +import com.epmet.dto.result.ResiRegisterLantuResultDTO; import com.epmet.dto.result.StaffOrgsResultDTO; import com.epmet.dto.result.UserTokenResultDTO; @@ -118,6 +119,13 @@ public interface ThirdLoginService { */ ResiDingAppLoginResDTO resiLoginHfive(HfiveLoginMdFormDTO formDTO); + /** + * 蓝图 居民端 注册 + * @param formDTO + * @return + */ + ResiRegisterLantuResultDTO resiRegisterLantu(ResiRegisterLantuFormDTO formDTO); + /** * desc:企业内部应用 工作端登录 * @param formDTO @@ -133,4 +141,6 @@ public interface ThirdLoginService { UserTokenResultDTO yanTaiSSOLogin(String authCode); void sendLoginEvent(String userId, String appId, String fromApp, String fromClient,String messageType); + + } diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java index 029168a24c..aba81afb14 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java @@ -1140,6 +1140,32 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol return resDTO; } + @Override + public ResiRegisterLantuResultDTO resiRegisterLantu(ResiRegisterLantuFormDTO formDTO) { + + // 最后返回给烟台的东西 最后可以跟我们系统关联起来 + ResiRegisterLantuResultDTO resiRegisterLantuResultDTO = new ResiRegisterLantuResultDTO(); + + // 用来注册居民端 + LantuRegisterResiFormDTO lantuRegisterResiFormDTO = new LantuRegisterResiFormDTO(); + // customer 给蓝图用 customerId 写死 烟台 +// lantuRegisterResiFormDTO.setCustomerId("1535072605621841922"); + lantuRegisterResiFormDTO.setCustomerId(getCurrentCustomerId()); + + lantuRegisterResiFormDTO.setMobile(formDTO.getPhone()); + lantuRegisterResiFormDTO.setNick(formDTO.getNick()); + lantuRegisterResiFormDTO.setAvatarUrl(formDTO.getAvatarUrl()); + lantuRegisterResiFormDTO.setGridId(formDTO.getGridId()); + + + // 注册 + Result lantuRegisterResi = epmetUserOpenFeignClient.lantuRegisterResi(lantuRegisterResiFormDTO); + + resiRegisterLantuResultDTO.setId(lantuRegisterResi.getData().getEpmetUserId()); + + return resiRegisterLantuResultDTO; + } + @Override public UserTokenResultDTO govLoginInternalDing(DingAppLoginMdFormDTO formDTO) { // 获取用户手机号 diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/AppClientConstant.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/AppClientConstant.java index a9cd108808..220cdff731 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/AppClientConstant.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/AppClientConstant.java @@ -37,6 +37,11 @@ public interface AppClientConstant { */ String MINI_DING = "mini_ding"; + /** + * 蓝图 + */ + String LAN_TU = "lan_tu"; + /** * H5 */ diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/LantuRegisterResiFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/LantuRegisterResiFormDTO.java new file mode 100644 index 0000000000..1541dd1a95 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/LantuRegisterResiFormDTO.java @@ -0,0 +1,40 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * @Description: lantu 注册 + * @Author: lichao + * @Date: 2023/8/15 10:18 + */ +@Data +public class LantuRegisterResiFormDTO { + + private String customerId; + + /** + * 头像URL。 + */ + private String avatarUrl; + + /** + * 用户的手机号。 + * 说明 如果要获取用户手机号,需要在开发者后台申请个人手机号信息权限,如下图。 + */ + private String mobile; + + /** + * 昵称 + */ + private String nick; + + /** + * 网格id + */ + private String gridId; + +} + diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/LantuRegisterResiResDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/LantuRegisterResiResDTO.java new file mode 100644 index 0000000000..5a6e2cc78f --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/LantuRegisterResiResDTO.java @@ -0,0 +1,34 @@ +package com.epmet.dto.result; + +import lombok.Data; + +/** + * @Description + * @Author yzm + * @Date 2022/9/15 9:33 + */ +@Data +public class LantuRegisterResiResDTO { + private String customerId; + private String gridId; + /** + * XXX社区-网格名 + */ + private String gridName; + /** + * 网格所属的组织id + */ + private String agencyId; + /** + * 居民端用户id + */ + private String epmetUserId; + + /** + * 是否注册居民 + * true:已注册 + * false:未注册 + */ + private Boolean regFlag; +} + diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java index 11fdd779d1..8d5e648d48 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java @@ -984,6 +984,10 @@ public interface EpmetUserOpenFeignClient { @PostMapping("/epmetuser/userbaseinfo/hFiveResiLogin") Result hFiveResiLogin(@RequestBody HfiveLoginResiFormDTO formDTO); + @PostMapping("/epmetuser/userbaseinfo/lantuRegisterResi") + Result lantuRegisterResi(@RequestBody LantuRegisterResiFormDTO formDTO); + + @PostMapping("/epmetuser/dataSyncConfig/dataSyncForYanTaiTask") Result dataSyncForYanTaiTask(@RequestBody DataSyncTaskParam formDTO); diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java index 3570d7e328..13240fb0bf 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java @@ -717,6 +717,11 @@ public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClien return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "hFiveResiLogin", formDTO); } + @Override + public Result lantuRegisterResi(LantuRegisterResiFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "lantuRegisterResi", formDTO); + } + @Override public Result dataSyncForYanTaiTask(DataSyncTaskParam formDTO) { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "dataSyncForYanTaiTask", formDTO); diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBaseInfoController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBaseInfoController.java index cfd30e57aa..4260d3f968 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBaseInfoController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBaseInfoController.java @@ -250,6 +250,18 @@ public class UserBaseInfoController { return new Result().ok(userBaseInfoService.hFiveResiLogin(formDTO)); } + /** + * @Description: lantu注册居民 + * @param formDTO: + * @Return com.epmet.commons.tools.utils.Result + * @Author: lichao + * @Date: 2023/8/15 10:18 + */ + @PostMapping("lantuRegisterResi") + public Result lantuRegisterResi(@RequestBody LantuRegisterResiFormDTO formDTO){ + return new Result().ok(userBaseInfoService.lantuRegisterResi(formDTO)); + } + /** * 来源于烟台需求,pc端新增菜单:用户完善信息列表 * @return diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBaseInfoService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBaseInfoService.java index 0c8f5a64ab..518675be67 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBaseInfoService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBaseInfoService.java @@ -222,6 +222,8 @@ public interface UserBaseInfoService extends BaseService { DingLoginResiResDTO hFiveResiLogin(HfiveLoginResiFormDTO formDTO); + LantuRegisterResiResDTO lantuRegisterResi(LantuRegisterResiFormDTO formDTO); + /** * 用户完善信息列表 * @param formDTO diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBaseInfoServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBaseInfoServiceImpl.java index 3d2c86b526..c033d36b4e 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBaseInfoServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBaseInfoServiceImpl.java @@ -22,10 +22,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; -import com.epmet.commons.tools.constant.AppClientConstant; -import com.epmet.commons.tools.constant.FieldConstant; -import com.epmet.commons.tools.constant.NumConstant; -import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.constant.*; import com.epmet.commons.tools.distributedlock.DistributedLock; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; @@ -38,17 +35,12 @@ import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.EpmetRequestHolder; import com.epmet.commons.tools.utils.NameUtils; import com.epmet.commons.tools.utils.Result; +import com.epmet.constant.UserRoleConstant; import com.epmet.dao.*; -import com.epmet.dto.RegisterRelationDTO; -import com.epmet.dto.UserBaseInfoDTO; -import com.epmet.dto.UserResiInfoDTO; -import com.epmet.dto.UserWechatDTO; +import com.epmet.dto.*; import com.epmet.dto.form.*; import com.epmet.dto.result.*; -import com.epmet.entity.RegisterRelationEntity; -import com.epmet.entity.UserBaseInfoEntity; -import com.epmet.entity.UserEntity; -import com.epmet.entity.UserWechatEntity; +import com.epmet.entity.*; import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.redis.UserBaseInfoRedis; import com.epmet.resi.partymember.dto.partymember.PartymemberInfoDTO; @@ -56,6 +48,7 @@ import com.epmet.resi.partymember.feign.ResiPartyMemberOpenFeignClient; import com.epmet.service.RegisterRelationService; import com.epmet.service.UserBaseInfoService; import com.epmet.service.UserResiInfoService; +import com.epmet.service.UserRoleService; import com.epmet.util.ModuleConstant; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; @@ -103,6 +96,13 @@ public class UserBaseInfoServiceImpl extends BaseServiceImpl registerWrapper = new LambdaQueryWrapper<>(); + registerWrapper.eq(RegisterRelationEntity::getCustomerId, formDTO.getCustomerId()); + registerWrapper.eq(RegisterRelationEntity::getUserId, baseInfo.getUserId()); + registerWrapper.eq(RegisterRelationEntity::getFirstRegister, NumConstant.ONE_STR); + RegisterRelationEntity registerRelation = registerRelationDao.selectOne(registerWrapper); + if (null == registerRelation){ + registerRelation = new RegisterRelationEntity(); + + registerRelation.setCustomerId(formDTO.getCustomerId()); + registerRelation.setGridId(formDTO.getGridId()); + //表中新增字段 为其赋值 + GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(formDTO.getGridId()); + if (null == gridInfo) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取网格缓存失败", "获取网格缓存失败"); + } + registerRelation.setAgencyId(gridInfo.getPid()); + registerRelation.setAgencyIdPath(gridInfo.getPids()); + registerRelation.setUserId(baseInfo.getUserId()); + //首次注册用户 (0表示不参与计数 1表示参与计数) + registerRelation.setFirstRegister(NumConstant.ONE_STR); + //注册用户 (0表示不参与计数 1表示参与计数) + registerRelation.setRegister(NumConstant.ONE_STR); + //参与用户 (0表示不参与计数 1表示参与计数) + registerRelation.setParticipation(NumConstant.ONE_STR); + registerRelationDao.insert(registerRelation); + }else{ + // 如果已经存在的话就更新 + registerRelation.setGridId(formDTO.getGridId()); + registerRelationDao.updateById(registerRelation); + } + + + // 先查询有没有用户居民端注册访问记录 新增用户居民端注册访问记录表 + LambdaQueryWrapper resiRegisterVisitLW = new LambdaQueryWrapper<>(); + resiRegisterVisitLW.eq(UserResiRegisterVisitEntity::getUserId,baseInfo.getUserId()); + resiRegisterVisitLW.eq(UserResiRegisterVisitEntity::getCustomerId,baseInfo.getCustomerId()); + UserResiRegisterVisitEntity visit = userResiRegisterVisitDao.selectOne(resiRegisterVisitLW); + if (visit == null){ + visit = new UserResiRegisterVisitEntity(); + visit.setCustomerId(baseInfo.getCustomerId()); + visit.setGridId(formDTO.getGridId()); + visit.setUserId(baseInfo.getUserId()); + visit.setVisitFrom("lantu"); + visit.setLastOperateVisit("success"); + visit.setVisitTime(new Date()); + userResiRegisterVisitDao.insert(visit); + }else{ + visit.setGridId(formDTO.getGridId()); + visit.setVisitFrom("lantu"); + visit.setLastOperateVisit("success"); + visit.setVisitTime(new Date()); + userResiRegisterVisitDao.updateById(visit); + } + + //新增该用户在该客户下的注册状态 + LambdaQueryWrapper userCustomerEntityLambdaQueryWrapper = new LambdaQueryWrapper<>(); + userCustomerEntityLambdaQueryWrapper.eq(UserCustomerEntity::getCustomerId,baseInfo.getCustomerId()); + userCustomerEntityLambdaQueryWrapper.eq(UserCustomerEntity::getUserId,baseInfo.getUserId()); + UserCustomerEntity userCustomer = userCustomerDao.selectOne(userCustomerEntityLambdaQueryWrapper); + if (userCustomer == null){ + userCustomer = new UserCustomerEntity(); + userCustomer.setCustomerId(baseInfo.getCustomerId()); + userCustomer.setUserId(baseInfo.getUserId()); + userCustomer.setIsRegister(NumConstant.ONE_STR); + userCustomerDao.insert(userCustomer); + }else{ + userCustomer.setIsRegister(NumConstant.ONE_STR); + userCustomerDao.updateById(userCustomer); + } + + //2:角色表新增角色数据 + LambdaQueryWrapper userRoleLambdaQueryWrapper = new LambdaQueryWrapper<>(); + userRoleLambdaQueryWrapper.eq(UserRoleEntity::getUserId,baseInfo.getUserId()); + userRoleLambdaQueryWrapper.eq(UserRoleEntity::getCustomerId,baseInfo.getCustomerId()); + UserRoleEntity userRoleEntity = userRoleDao.selectOne(userRoleLambdaQueryWrapper); + if (userRoleEntity == null){ + UserRoleDTO userRoleDTO = new UserRoleDTO(); + userRoleDTO.setCustomerId(baseInfo.getCustomerId()); + userRoleDTO.setUserId(baseInfo.getUserId()); + userRoleDTO.setApp("resi"); + userRoleDTO.setRoleKey(EpmetRoleKeyConstant.REGISTERED_RESI); + //居民角色对应的网格Id存默认值-all + userRoleDTO.setGridId(UserRoleConstant.DEFAULT_GRID_ID); + userRoleService.saveUserRole(userRoleDTO); + } + } finally { + distributedLock.unLock(lock); + } + return result; + } + /** * 用户完善信息列表 *