| | |
| | | package cn.huge.module.ctuser.service; |
| | | |
| | | import cn.huge.base.common.bo.R; |
| | | import cn.huge.base.common.bo.ReturnBO; |
| | | import cn.huge.base.common.exception.ServiceException; |
| | | import cn.huge.base.common.utils.*; |
| | |
| | | import cn.huge.module.client.api.impl.UtilsClientImpl; |
| | | import cn.huge.module.ctuser.dao.mapper.CtAccountMapper; |
| | | import cn.huge.module.ctuser.domain.po.CtAccount; |
| | | import cn.huge.module.ctuser.domain.po.CtUnit; |
| | | import cn.huge.module.ctuser.domain.po.CtUser; |
| | | import cn.huge.module.ctuser.domain.po.CtUserole; |
| | | import cn.huge.module.ctuser.dto.CtAccountLoginDTO; |
| | | import cn.huge.module.ctuser.dto.CtCipherDTO; |
| | | import cn.huge.module.ctuser.dto.CtUserAddrDTO; |
| | | import cn.huge.module.ctuser.dto.UserLoginDTO; |
| | | import cn.huge.module.ctuser.dto.*; |
| | | import cn.huge.module.cust.constant.UserBaseConsts; |
| | | import cn.huge.module.sys.dto.GridTokenBaseDTO; |
| | | import cn.huge.module.sys.dto.GridUserBaseDTO; |
| | | import cn.huge.module.sys.dto.GridUserRoleDTO; |
| | | import cn.huge.module.sys.vo.GridRoleMenuVo; |
| | | import cn.huge.module.sys.vo.GridUserRoleVo; |
| | | import cn.huge.module.utils.JwtUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | |
| | | import org.springframework.util.DigestUtils; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author liyj |
| | | * @version 1.0.0 |
| | | * @title: 客户用户账号表业务逻辑处理 |
| | | * @Description 客户用户账号表业务逻辑处理 |
| | | * @company hugeinfo |
| | | * @author liyj |
| | | * @Time 2024-08-19 20:04:18 |
| | | * @version 1.0.0 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public class CtAccountService extends ServiceImpl<CtAccountMapper, CtAccount>{ |
| | | public class CtAccountService extends ServiceImpl<CtAccountMapper, CtAccount> { |
| | | |
| | | @Autowired |
| | | private CtAccountMapper mapper; |
| | |
| | | private CtUseroleService ctUseroleService; |
| | | @Autowired |
| | | private SysClientImpl sysClient; |
| | | @Autowired |
| | | private CtUnitService ctUnitService; |
| | | |
| | | /** |
| | | * 更新对象 |
| | | * @param entity 对象 |
| | | */ |
| | | public void updateCtAccount(CtAccount entity){ |
| | | try{ |
| | | * 更新对象 |
| | | * |
| | | * @param entity 对象 |
| | | */ |
| | | public void updateCtAccount(CtAccount entity) { |
| | | try { |
| | | mapper.updateCtAccount(entity); |
| | | }catch (Exception e){ |
| | | log.error("[CtAccountService.updateCtAccount]调用失败,异常信息:"+e, e); |
| | | } catch (Exception e) { |
| | | log.error("[CtAccountService.updateCtAccount]调用失败,异常信息:" + e, e); |
| | | throw new ServiceException("CtAccountService.updateCtAccount", e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 条件更新对象 |
| | | * @param entity 对象 |
| | | * @param terms 条件 |
| | | */ |
| | | public void updateCtAccountTerms(CtAccount entity, Map<String, Object> terms){ |
| | | try{ |
| | | * 条件更新对象 |
| | | * |
| | | * @param entity 对象 |
| | | * @param terms 条件 |
| | | */ |
| | | public void updateCtAccountTerms(CtAccount entity, Map<String, Object> terms) { |
| | | try { |
| | | mapper.updateCtAccountTerms(entity, terms); |
| | | }catch (Exception e){ |
| | | log.error("[CtAccountService.updateCtAccountTerms]调用失败,异常信息:"+e, e); |
| | | } catch (Exception e) { |
| | | log.error("[CtAccountService.updateCtAccountTerms]调用失败,异常信息:" + e, e); |
| | | throw new ServiceException("CtAccountService.updateCtAccountTerms", e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据编号物理删除 |
| | | * @param id 查询条件集合 |
| | | */ |
| | | public void deleteCtAccount(String id){ |
| | | try{ |
| | | * 根据编号物理删除 |
| | | * |
| | | * @param id 查询条件集合 |
| | | */ |
| | | public void deleteCtAccount(String id) { |
| | | try { |
| | | mapper.deleteCtAccount(id); |
| | | }catch (Exception e){ |
| | | log.error("[CtAccountService.deleteCtAccount]调用失败,异常信息:"+e, e); |
| | | } catch (Exception e) { |
| | | log.error("[CtAccountService.deleteCtAccount]调用失败,异常信息:" + e, e); |
| | | throw new ServiceException("CtAccountService.deleteCtAccount", e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 按条件查询 |
| | | * @param terms 条件 |
| | | * @return List |
| | | */ |
| | | public List<CtAccount> listTerms(Map<String, Object> terms){ |
| | | * 按条件查询 |
| | | * |
| | | * @param terms 条件 |
| | | * @return List |
| | | */ |
| | | public List<CtAccount> listTerms(Map<String, Object> terms) { |
| | | return mapper.listTerms(terms); |
| | | } |
| | | |
| | | /** |
| | | * 按条件统计 |
| | | * @param terms 条件 |
| | | * @return long |
| | | */ |
| | | public long countTerms(Map<String, Object> terms){ |
| | | * 按条件统计 |
| | | * |
| | | * @param terms 条件 |
| | | * @return long |
| | | */ |
| | | public long countTerms(Map<String, Object> terms) { |
| | | return mapper.countTerms(terms); |
| | | } |
| | | |
| | | /** |
| | | * 按条件分页查询 |
| | | * @param page 分页对象 |
| | | * @param terms 条件 |
| | | * @return Page |
| | | */ |
| | | public Page<CtAccount> pageQuery(PageRequest page, Map<String, Object> terms){ |
| | | * 按条件分页查询 |
| | | * |
| | | * @param page 分页对象 |
| | | * @param terms 条件 |
| | | * @return Page |
| | | */ |
| | | public Page<CtAccount> pageQuery(PageRequest page, Map<String, Object> terms) { |
| | | long total = mapper.countTerms(terms); |
| | | List<CtAccount> content = mapper.pageTerms(page, terms); |
| | | return new PageImpl<CtAccount>(content, page, total); |
| | | } |
| | | |
| | | /** |
| | | * 新增或更新对象 |
| | | * @param ctAccount 实体对象 |
| | | */ |
| | | public void saveCtAccount(CtAccount ctAccount){ |
| | | try{ |
| | | * 新增或更新对象 |
| | | * |
| | | * @param ctAccount 实体对象 |
| | | */ |
| | | public void saveCtAccount(CtAccount ctAccount) { |
| | | try { |
| | | Date nowDate = DateUtils.getNowDate(); |
| | | // 判断是否新增 |
| | | if (IdUtils.checkNewId(ctAccount.getId())){ |
| | | if (IdUtils.checkNewId(ctAccount.getId())) { |
| | | ctAccount.setId(utilsClient.getNewTimeId()); |
| | | ctAccount.setCreateTime(nowDate); |
| | | } |
| | | ctAccount.setUpdateTime(nowDate); |
| | | this.saveOrUpdate(ctAccount); |
| | | }catch (Exception e){ |
| | | log.error("[CtAccountService.saveCtAccount]调用失败,异常信息:"+e, e); |
| | | } catch (Exception e) { |
| | | log.error("[CtAccountService.saveCtAccount]调用失败,异常信息:" + e, e); |
| | | throw new ServiceException("CtAccountService.saveCtAccount", e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据账号和类型查询 |
| | | * @param acc 账号 |
| | | * |
| | | * @param acc 账号 |
| | | * @param accType 账号类型 |
| | | * @return |
| | | */ |
| | | public CtAccount getByAccAndType(String acc, int accType){ |
| | | public CtAccount getByAccAndType(String acc, int accType) { |
| | | QueryWrapper<CtAccount> accountWrapper = new QueryWrapper<>(); |
| | | accountWrapper.eq("acc", acc) |
| | | .eq("acc_type", accType); |
| | |
| | | |
| | | /** |
| | | * 根据用户编号和类型查询 |
| | | * @param userId 用户编号 |
| | | * |
| | | * @param userId 用户编号 |
| | | * @param accType 账号类型 |
| | | * @return |
| | | */ |
| | | public CtAccount getByUserIdAndType(String userId, int accType){ |
| | | public CtAccount getByUserIdAndType(String userId, int accType) { |
| | | QueryWrapper<CtAccount> accountWrapper = new QueryWrapper<>(); |
| | | accountWrapper.eq("user_id", userId) |
| | | .eq("acc_type", accType); |
| | |
| | | |
| | | /** |
| | | * 判断密码是否正确 |
| | | * @param cipher 密码 |
| | | * |
| | | * @param cipher 密码 |
| | | * @param ctAccount 账号信息 |
| | | * @return Boolean |
| | | */ |
| | | public Boolean checkCredential(String cipher, CtAccount ctAccount){ |
| | | public Boolean checkCredential(String cipher, CtAccount ctAccount) { |
| | | String credentialMd5 = DigestUtils.md5DigestAsHex(cipher.getBytes()); |
| | | if (StringUtils.equals(credentialMd5, ctAccount.getCipher())) { |
| | | return true; |
| | | }else { |
| | | } else { |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | String createTime = sdf.format(ctAccount.getCreateTime()); |
| | | String credentialTime = sdf.format(ctAccount.getCreateTime()); |
| | |
| | | if (createTime.equals(credentialTime)) { |
| | | if (cipher.equals(UserBaseConsts.MR_CIPHER)) { |
| | | return true; |
| | | }else{ |
| | | } else { |
| | | return false; |
| | | } |
| | | }else{ |
| | | } else { |
| | | return false; |
| | | } |
| | | } |
| | |
| | | |
| | | /** |
| | | * web端-工作人员用户登录 |
| | | * |
| | | * @param ctAccountLoginDTO 登录账号信息 |
| | | * @return UserLoginDTO |
| | | */ |
| | | public ReturnBO webLogin(CtAccountLoginDTO ctAccountLoginDTO) { |
| | | try{ |
| | | try { |
| | | // 判断账号密码是否为空 |
| | | if (StringUtils.isBlank(ctAccountLoginDTO.getAcc()) || StringUtils.isBlank(ctAccountLoginDTO.getCipher())) { |
| | | return ReturnFailUtils.getRepInfo("账号或密码不能为空"); |
| | | } |
| | | // 判断账号是否存在 |
| | | CtAccount ctAccount = this.getByAccAndType(ctAccountLoginDTO.getAcc(), UserBaseConsts.ACC_TYPE_1); |
| | | if (ObjectUtils.isNotEmpty(ctAccount)){ |
| | | if (ObjectUtils.isNotEmpty(ctAccount)) { |
| | | // 判断账号是否被锁定 |
| | | if (ObjectUtils.isNotEmpty(ctAccount.getLimitTime())) { |
| | | Date nowDate = new Date(); |
| | |
| | | //返回结果 |
| | | UserLoginDTO userLoginDTO = new UserLoginDTO(); |
| | | CtUser ctUser = ctUserService.getById(ctAccount.getUserId()); |
| | | if (ObjectUtils.isEmpty(ctUser)){ |
| | | if (ObjectUtils.isEmpty(ctUser)) { |
| | | return ReturnFailUtils.getRepInfo("账号或密码错误,请确认后重试!"); |
| | | } |
| | | if (ctUser.getStatus() != UserBaseConsts.USER_STATUS_1){ |
| | | if (ctUser.getStatus() != UserBaseConsts.USER_STATUS_1) { |
| | | return ReturnFailUtils.getRepInfo("账号或密码错误,请确认后重试!"); |
| | | } |
| | | // 封装用户信息 |
| | | userLoginDTO.setToken(JwtUtils.buildJWT(ctUser.getId())); |
| | | userLoginDTO.setUserId(ctUser.getId()); |
| | | userLoginDTO.setTrueName(ctUser.getTrueName()); |
| | | userLoginDTO.setUnit(ctUser.getUnitName()); |
| | | CtUnit ctUnit = ctUnitService.getById(ctUser.getUnitId()); |
| | | if (ObjectUtils.isNotEmpty(ctUnit)){ |
| | | if (ctUnit.getUnitGrade() == UserBaseConsts.UNIT_GRADE_3 && ctUnit.getUnitType() == UserBaseConsts.UNIT_TYPE_102){ |
| | | userLoginDTO.setUnit(ctUnit.getUnitDes()); |
| | | // CtUnit parentCtUnit = ctUnitService.getById(ctUnit.getParentId()); |
| | | // if (ObjectUtils.isNotEmpty(parentCtUnit)) {1 |
| | | // userLoginDTO.setUnit(parentCtUnit.getUnitName()); |
| | | // }else { |
| | | // userLoginDTO.setUnit(ctUnit.getUnitDes()); |
| | | // } |
| | | }else { |
| | | userLoginDTO.setUnit(ctUnit.getUnitName()); |
| | | } |
| | | }else { |
| | | userLoginDTO.setUnit(ctUser.getUnitName()); |
| | | } |
| | | userLoginDTO.setDept(ctUser.getDeptName()); |
| | | userLoginDTO.setCustId(ctUser.getCustId()); |
| | | // 登录用户角色 |
| | |
| | | userLoginDTO.setCtUserAddrDTO(ctUserAddrDTO); |
| | | // 最后登录时间 |
| | | Date loginTime = ctAccount.getLoginTime(); |
| | | if (ObjectUtils.isEmpty(ctAccount.getLoginTime())){ |
| | | if (ObjectUtils.isEmpty(ctAccount.getLoginTime())) { |
| | | loginTime = DateUtils.getNowDate(); |
| | | } |
| | | userLoginDTO.setLastLoginTime(loginTime); |
| | |
| | | } else { |
| | | return ReturnFailUtils.getRepInfo("账号或密码错误,请确认后重试!"); |
| | | } |
| | | }else{ |
| | | } else { |
| | | return ReturnFailUtils.getRepInfo("账号或密码错误,请确认后重试!"); |
| | | } |
| | | }catch (Exception e){ |
| | | log.error("service方法[AccountService.webLogin]调用失败,异常信息:"+e, e); |
| | | } catch (Exception e) { |
| | | log.error("service方法[AccountService.webLogin]调用失败,异常信息:" + e, e); |
| | | throw new ServiceException("CtAccountService.webLogin", e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * web端-工作人员-修改密码 |
| | | * @param userId 用户编号 |
| | | * |
| | | * @param userId 用户编号 |
| | | * @param ctCipherDTO 修改密码信息 |
| | | * @return |
| | | */ |
| | | public ReturnBO webChangeCipher(String userId, CtCipherDTO ctCipherDTO){ |
| | | try{ |
| | | public ReturnBO webChangeCipher(String userId, CtCipherDTO ctCipherDTO) { |
| | | try { |
| | | CtUser loginUser = ctUserService.getById(userId); |
| | | CtAccount ctAccount = this.getByAccAndType(loginUser.getAcc(), UserBaseConsts.ACC_TYPE_1); |
| | | // QueryWrapper<CtAccount> ctAccountQueryWrapper = new QueryWrapper<>(); |
| | | // ctAccountQueryWrapper.eq("user_id", loginUser.getId()). |
| | | // eq("acc_type", UserBaseConsts.ACC_TYPE_1); |
| | | // CtAccount ctAccount =mapper.selectOne(ctAccountQueryWrapper); |
| | | if (ObjectUtils.isEmpty(ctAccount)){ |
| | | if (ObjectUtils.isEmpty(ctAccount)) { |
| | | return ReturnFailUtils.getRepInfo("输入账号或密码不正确,请确认后重试!"); |
| | | } |
| | | String oldCredentialMd5 = DigestUtils.md5DigestAsHex(ctCipherDTO.getOldCipher().getBytes()); |
| | |
| | | .set("update_time", DateUtils.getNowDate()).eq("id", ctAccount.getId()); |
| | | this.update(accountUpdateWrapper); |
| | | return ReturnSucUtils.getRepInfo(); |
| | | }catch (Exception e){ |
| | | log.error("service方法[AccountService.webChangeCipher]调用失败,异常信息:"+e, e); |
| | | } catch (Exception e) { |
| | | log.error("service方法[AccountService.webChangeCipher]调用失败,异常信息:" + e, e); |
| | | throw new ServiceException("CtAccountService.webChangeCipher", e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * web端-网格系统单点登录 |
| | | * |
| | | * @param gridTokenBaseDTO 网格系统token |
| | | * @return UserLoginDTO |
| | | */ |
| | | public ReturnBO webGridLogin(GridTokenBaseDTO gridTokenBaseDTO) { |
| | | try{ |
| | | try { |
| | | GridUserBaseDTO gridUserBaseDTO = sysClient.getUserInfo(gridTokenBaseDTO); |
| | | |
| | | // 判断账号密码是否为空 |
| | |
| | | return ReturnFailUtils.getRepInfo("gridToken已失效,请重新登录!"); |
| | | } |
| | | // 判断账号是否存在 |
| | | CtAccount ctAccount = this.getByAccAndType(gridUserBaseDTO.getAccount(), UserBaseConsts.ACC_TYPE_1); |
| | | if (ObjectUtils.isNotEmpty(ctAccount)){ |
| | | CtAccount ctAccount = null; |
| | | CtUser ctUser = null; |
| | | ctAccount = this.getByAccAndType(gridUserBaseDTO.getAccount(), UserBaseConsts.ACC_TYPE_1); |
| | | if (ObjectUtils.isEmpty(ctAccount)) { |
| | | ctAccount = this.getByAccAndType(gridUserBaseDTO.getMobile(), UserBaseConsts.ACC_TYPE_1); |
| | | } |
| | | if (ObjectUtils.isNotEmpty(ctAccount)) { |
| | | //返回结果 |
| | | UserLoginDTO userLoginDTO = new UserLoginDTO(); |
| | | CtUser ctUser = ctUserService.getById(ctAccount.getUserId()); |
| | | if (ObjectUtils.isEmpty(ctUser)){ |
| | | ctUser = ctUserService.getById(ctAccount.getUserId()); |
| | | if (ObjectUtils.isEmpty(ctUser)) { |
| | | return ReturnFailUtils.getRepInfo("用户不存在!"); |
| | | } |
| | | // 封装用户信息 |
| | | userLoginDTO.setToken(JwtUtils.buildJWT(ctUser.getId())); |
| | | userLoginDTO.setUserId(ctUser.getId()); |
| | | userLoginDTO.setTrueName(ctUser.getTrueName()); |
| | | userLoginDTO.setUnit(ctUser.getUnitName()); |
| | | userLoginDTO.setDept(ctUser.getDeptName()); |
| | | userLoginDTO.setCustId(ctUser.getCustId()); |
| | | // 登录用户角色 |
| | | List<CtUserole> ctUseroleList = ctUseroleService.listByUserId(ctUser.getId()); |
| | | userLoginDTO.setCtUseroleList(ctUseroleList); |
| | | // 登录用户地址信息 |
| | | CtUserAddrDTO ctUserAddrDTO = new CtUserAddrDTO(); |
| | | ctUserAddrDTO.setProv(ctUser.getProv()); |
| | | ctUserAddrDTO.setProvName(ctUser.getProvName()); |
| | | ctUserAddrDTO.setCity(ctUser.getCity()); |
| | | ctUserAddrDTO.setCityName(ctUser.getCityName()); |
| | | ctUserAddrDTO.setArea(ctUser.getArea()); |
| | | ctUserAddrDTO.setAreaName(ctUser.getAreaName()); |
| | | ctUserAddrDTO.setRoad(ctUser.getRoad()); |
| | | ctUserAddrDTO.setRoadName(ctUser.getRoadName()); |
| | | ctUserAddrDTO.setVillage(ctUser.getVillage()); |
| | | ctUserAddrDTO.setVillageName(ctUser.getVillageName()); |
| | | userLoginDTO.setCtUserAddrDTO(ctUserAddrDTO); |
| | | // 最后登录时间 |
| | | Date loginTime = ctAccount.getLoginTime(); |
| | | if (ObjectUtils.isEmpty(ctAccount.getLoginTime())){ |
| | | loginTime = DateUtils.getNowDate(); |
| | | } else { |
| | | //如果和亿迅系统的手机号对不上,在用身份证号去查询用户,如果查询得到,就对得上,如果查询不到,就说明用户不存在 |
| | | ctUser = ctUserService.getByIdCard(gridUserBaseDTO.getIdNumber()); |
| | | if (ObjectUtils.isNotEmpty(ctUser)) { |
| | | ctAccount = this.getByUserIdAndType(ctUser.getId(), UserBaseConsts.ACC_TYPE_1); |
| | | } |
| | | userLoginDTO.setLastLoginTime(loginTime); |
| | | // 更新最新登录时间 |
| | | UpdateWrapper<CtAccount> accountUpdateWrapper = new UpdateWrapper<>(); |
| | | accountUpdateWrapper.set("login_time", loginTime).eq("id", ctAccount.getId()); |
| | | this.update(accountUpdateWrapper); |
| | | return ReturnSucUtils.getRepInfo(userLoginDTO); |
| | | }else{ |
| | | return ReturnFailUtils.getRepInfo("用户不存在!,请确认后重试!"); |
| | | } |
| | | }catch (Exception e){ |
| | | log.error("service方法[AccountService.webGridLogin]调用失败,异常信息:"+e, e); |
| | | if (ObjectUtils.isNotEmpty(ctUser)) { |
| | | //有对应用户,则模拟登录,返回对应信息 |
| | | UserLoginDTO userLoginDTO = login(ctAccount, ctUser); |
| | | return ReturnSucUtils.getRepInfo(userLoginDTO); |
| | | } else { |
| | | //没有对应用户,创建用户,根据用户id获取用户信息 |
| | | ReturnBO repInfo = initNewUser(gridUserBaseDTO); |
| | | if (repInfo.getCode() == 0) { |
| | | //创建用户成功,模拟登录 |
| | | ctUser = ctUserService.getByIdCard(gridUserBaseDTO.getIdNumber()); |
| | | if (ObjectUtils.isNotEmpty(ctUser)) { |
| | | ctAccount = this.getByUserIdAndType(ctUser.getId(), UserBaseConsts.ACC_TYPE_1); |
| | | } |
| | | UserLoginDTO userLoginDTO = login(ctAccount, ctUser); |
| | | return ReturnSucUtils.getRepInfo(userLoginDTO); |
| | | } else { |
| | | //创建用户失败,返回失败信息 |
| | | return repInfo; |
| | | } |
| | | |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("service方法[AccountService.webGridLogin]调用失败,异常信息:" + e, e); |
| | | throw new ServiceException("CtAccountService.webGridLogin", e); |
| | | } |
| | | } |
| | | |
| | | private UserLoginDTO login(CtAccount ctAccount, CtUser ctUser) { |
| | | UserLoginDTO userLoginDTO = new UserLoginDTO(); |
| | | // 封装用户信息 |
| | | userLoginDTO.setToken(JwtUtils.buildJWT(ctUser.getId())); |
| | | userLoginDTO.setUserId(ctUser.getId()); |
| | | userLoginDTO.setTrueName(ctUser.getTrueName()); |
| | | userLoginDTO.setUnit(ctUser.getUnitName()); |
| | | userLoginDTO.setDept(ctUser.getDeptName()); |
| | | userLoginDTO.setCustId(ctUser.getCustId()); |
| | | // 登录用户角色 |
| | | List<CtUserole> ctUseroleList = ctUseroleService.listByUserId(ctUser.getId()); |
| | | userLoginDTO.setCtUseroleList(ctUseroleList); |
| | | // 登录用户地址信息 |
| | | CtUserAddrDTO ctUserAddrDTO = new CtUserAddrDTO(); |
| | | ctUserAddrDTO.setProv(ctUser.getProv()); |
| | | ctUserAddrDTO.setProvName(ctUser.getProvName()); |
| | | ctUserAddrDTO.setCity(ctUser.getCity()); |
| | | ctUserAddrDTO.setCityName(ctUser.getCityName()); |
| | | ctUserAddrDTO.setArea(ctUser.getArea()); |
| | | ctUserAddrDTO.setAreaName(ctUser.getAreaName()); |
| | | ctUserAddrDTO.setRoad(ctUser.getRoad()); |
| | | ctUserAddrDTO.setRoadName(ctUser.getRoadName()); |
| | | ctUserAddrDTO.setVillage(ctUser.getVillage()); |
| | | ctUserAddrDTO.setVillageName(ctUser.getVillageName()); |
| | | userLoginDTO.setCtUserAddrDTO(ctUserAddrDTO); |
| | | // 最后登录时间 |
| | | Date loginTime = new Date(); |
| | | userLoginDTO.setLastLoginTime(loginTime); |
| | | // 更新最新登录时间 |
| | | UpdateWrapper<CtAccount> accountUpdateWrapper = new UpdateWrapper<>(); |
| | | accountUpdateWrapper.set("login_time", loginTime).eq("id", ctAccount.getId()); |
| | | this.update(accountUpdateWrapper); |
| | | return userLoginDTO; |
| | | } |
| | | |
| | | private ReturnBO initNewUser(GridUserBaseDTO gridUserBaseDTO) { |
| | | String userId = gridUserBaseDTO.getId(); |
| | | //拿到用户机构信息 |
| | | GridUserRoleVo gridUserRoleVo = new GridUserRoleVo(); |
| | | gridUserRoleVo.setUserId(userId); |
| | | GridUserRoleDTO userRoleDTO = sysClient.getUserRoleList(gridUserRoleVo); |
| | | if (StringUtils.isEmpty(userRoleDTO.getRoleName()) || !userRoleDTO.getRoleName().contains("矛调系统")) { |
| | | return ReturnFailUtils.getRepInfo("该用户没有矛调系统的权限"); |
| | | } |
| | | if (StringUtils.isNotEmpty(userRoleDTO.getOrgName()) && userRoleDTO.getOrgName().endsWith("网格")) { |
| | | return ReturnFailUtils.getRepInfo("该用户所在机构禁止登录矛调系统,请切换该用户机构为区、镇街、社区机构"); |
| | | } |
| | | CtUserole ctUserole = new CtUserole(); |
| | | if (userRoleDTO.getRoleName().contains("纷化解人员")) { |
| | | ctUserole.setRoleId("22_00024-4"); |
| | | ctUserole.setRoleName("纠纷化解人员"); |
| | | } else { |
| | | ctUserole.setRoleId("22_00024-3"); |
| | | ctUserole.setRoleName("单位管理员"); |
| | | } |
| | | |
| | | List<CtUserole> ctUseroles = new ArrayList<>(); |
| | | ctUseroles.add(ctUserole); |
| | | log.info("xsd:CtUserole:{}", ctUserole); |
| | | CtUnit ctUnit = ctUnitService.selectUnitByGridId(userRoleDTO.getOrgId()); |
| | | log.info("xsd:ctUnit:{}", ctUnit); |
| | | if (ctUnit != null && StringUtils.isNotEmpty(ctUnit.getId())) { |
| | | CtUserSaveDTO ctUserSaveDTO = new CtUserSaveDTO(); |
| | | ctUserSaveDTO.setUnitId(ctUnit.getId()); |
| | | ctUserSaveDTO.setUnitName(ctUnit.getUnitName()); |
| | | ctUserSaveDTO.setCipher("byzfw2023!"); |
| | | ctUserSaveDTO.setAcc(gridUserBaseDTO.getMobile()); |
| | | ctUserSaveDTO.setTrueName(gridUserBaseDTO.getName()); |
| | | ctUserSaveDTO.setMobile(gridUserBaseDTO.getMobile()); |
| | | ctUserSaveDTO.setIdcard(gridUserBaseDTO.getIdNumber()); |
| | | ctUserSaveDTO.setCtUseroleList(ctUseroles); |
| | | ctUserService.webSaveCtUser(ctUserSaveDTO, "-1"); |
| | | log.info("xsd:ctUserSaveDTO:{}", ctUserSaveDTO); |
| | | } else { |
| | | return ReturnFailUtils.getRepInfo("该用户所在机构禁止登录矛调系统!请调整机构后重试!"); |
| | | } |
| | | return ReturnSucUtils.getRepInfo("创建账号成功"); |
| | | } |
| | | |
| | | } |