| | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.PhoneUtil; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.xiaopeng.account.constant.I18nKeyConstant; |
| | | import com.xiaopeng.account.mapper.SysRoleMapper; |
| | | import com.xiaopeng.account.mapper.XpOperationsRoleMapper; |
| | |
| | | import com.xiaopeng.account.model.dto.XpOperationsUserDTO; |
| | | import com.xiaopeng.account.model.query.XpOperationsUserPageQuery; |
| | | import com.xiaopeng.account.model.query.XpOperationsUserQuery; |
| | | import com.xiaopeng.account.service.ISysRoleService; |
| | | import com.xiaopeng.account.service.IXpOperationsRoleService; |
| | | import com.xiaopeng.account.service.IXpOperationsUserService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.xiaopeng.account.service.IXpQualificationAuditService; |
| | | import com.xiaopeng.account.service.*; |
| | | import com.xiaopeng.account.util.AliOssDownloadUtil; |
| | | import com.xiaopeng.api.dto.account.XpOperationsUserQueryDTO; |
| | | import com.xiaopeng.api.feignClient.maintenance.XpClockInClient; |
| | | import com.xiaopeng.api.feignClient.vehicleConvoy.XpFleetClient; |
| | | import com.xiaopeng.api.feignClient.vehicleConvoy.XpFleetOperationsClient; |
| | | import com.xiaopeng.api.model.account.*; |
| | | import com.xiaopeng.api.model.account.SysRole; |
| | | import com.xiaopeng.api.model.account.XpOperationsRole; |
| | | import com.xiaopeng.api.model.account.XpOperationsUser; |
| | | import com.xiaopeng.api.model.account.XpQualificationAudit; |
| | | import com.xiaopeng.api.model.vehicleConvoy.XpFleet; |
| | | import com.xiaopeng.api.query.account.OptionalUsersPageListQuery; |
| | | import com.xiaopeng.api.vo.account.*; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.exception.ServiceException; |
| | | import com.xiaopeng.common.core.utils.poi.ExcelUtil; |
| | | import com.xiaopeng.common.core.web.page.PageInfo; |
| | | import com.xiaopeng.common.security.utils.SecurityUtils; |
| | | import com.xiaopeng.evi.oss.service.AliOssService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shardingsphere.transaction.annotation.ShardingSphereTransactionType; |
| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.Serializable; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | import java.util.function.Function; |
| | |
| | | private SysRoleMapper sysRoleMapper; |
| | | @Autowired |
| | | private ISysRoleService iSysRoleService; |
| | | @Autowired |
| | | private AliOssService aliOssService; |
| | | @Autowired |
| | | private AliOssDownloadUtil aliOssDownloadUtil; |
| | | @Autowired |
| | | private ISysGroupService sysGroupService; |
| | | |
| | | @Override |
| | | public XpOperationsUser getById(Serializable userId){ |
| | | XpOperationsUser user = baseMapper.selectById(userId); |
| | | //获取登录用户权限信息 |
| | | user.setPhoneNumber(sysGroupService.getPhoneDesensitization(user.getPhoneNumber())); |
| | | return user; |
| | | } |
| | | |
| | | @Override |
| | | public List<XpOperationsUser> listByName(String nickName) { |
| | | if (StringUtils.isBlank(nickName)) { |
| | | return Collections.emptyList(); |
| | | } |
| | | return lambdaQuery().like(XpOperationsUser::getNickName, nickName).list(); |
| | | List<XpOperationsUser> list = lambdaQuery().like(XpOperationsUser::getNickName, nickName).list(); |
| | | for (XpOperationsUser obj : list) { |
| | | obj.setPhoneNumber(sysGroupService.getPhoneDesensitization(obj.getPhoneNumber())); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public PageInfo<XpOperationsUserWithRoleVO> selectUserPageByConditions(XpOperationsUserPageQuery query) { |
| | | PageInfo<XpOperationsUserWithRoleVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); |
| | | Page<XpOperationsUserWithRoleVO> page = baseMapper.selectUserPageByConditions(pageInfo, query); |
| | | for (XpOperationsUserWithRoleVO record : page.getRecords()) { |
| | | record.setPhoneNumber(sysGroupService.getPhoneDesensitization(record.getPhoneNumber())); |
| | | } |
| | | pageInfo.setRecords(page.getRecords()); |
| | | return pageInfo; |
| | | } |
| | | |
| | | @Override |
| | | public List<XpOperationsUserWithRoleVO> findList(XpOperationsUserQueryDTO query){ |
| | | return baseMapper.selectUserPageByConditions(query); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | XpOperationsUserProfileVO vo = new XpOperationsUserProfileVO(); |
| | | BeanUtils.copyProperties(user, vo); |
| | | |
| | | vo.setPhoneNumber(sysGroupService.getPhoneDesensitization(vo.getPhoneNumber())); |
| | | vo.setAvatar(aliOssDownloadUtil.getPictureJSONObject(vo.getAvatar())); |
| | | // 2. 查询关联的车队ID列表(一个运维人员只能关联一个车队) |
| | | R<List<Long>> fleetIdsResult = xpFleetOperationsClient.getFleetIdsByUserId(userId); |
| | | List<Long> fleetIds = fleetIdsResult.getData(); |
| | |
| | | |
| | | // 7. 查询是否上班中 |
| | | try { |
| | | R<Boolean> workStatusResult = xpClockInClient.checkWorkStatus(userId); |
| | | R<Integer> workStatusResult = xpClockInClient.checkWorkStatus(userId); |
| | | if (workStatusResult != null && workStatusResult.getCode() == 200) { |
| | | vo.setWorkFlag(workStatusResult.getData()); |
| | | } else { |
| | | // 调用失败,默认 false |
| | | vo.setWorkFlag(false); |
| | | vo.setWorkFlag(1); |
| | | log.warn("查询用户上班状态失败, userId={}, result={}", userId, workStatusResult); |
| | | } |
| | | } catch (Exception e) { |
| | | // 异常情况,默认 false |
| | | vo.setWorkFlag(false); |
| | | vo.setWorkFlag(1); |
| | | log.error("查询用户上班状态异常, userId={}", userId, e); |
| | | } |
| | | |
| | |
| | | @Transactional |
| | | @ShardingSphereTransactionType(TransactionType.BASE) |
| | | public void saveCertificate(XpOperationsUserDTO dto) { |
| | | XpOperationsUser xpOperationsUser = BeanUtil.copyProperties(dto, XpOperationsUser.class); |
| | | updateById(xpOperationsUser); |
| | | // XpOperationsUser xpOperationsUser = BeanUtil.copyProperties(dto, XpOperationsUser.class); |
| | | // updateById(xpOperationsUser); |
| | | //保存审核记录 |
| | | XpQualificationAudit xpQualificationAudit = BeanUtil.copyProperties(dto, XpQualificationAudit.class, "id"); |
| | | xpQualificationAudit.setAuditStatus(1); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | for (XpOperationsUserVO xpOperationsUserVO : list) { |
| | | xpOperationsUserVO.setPhoneNumber(sysGroupService.getPhoneDesensitization(xpOperationsUserVO.getPhoneNumber())); |
| | | String avatar = xpOperationsUserVO.getAvatar(); |
| | | // 处理空的情况 |
| | | if (avatar == null) { |
| | | continue; |
| | | } |
| | | JSONObject jsonObject = JSONObject.parseObject(avatar); |
| | | String downloadUrl = null; |
| | | try { |
| | | // 1 |
| | | if(Objects.nonNull(jsonObject)){ |
| | | downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); |
| | | jsonObject.put("url", downloadUrl); |
| | | xpOperationsUserVO.setAvatar(jsonObject.toJSONString()); |
| | | } |
| | | } catch (UnsupportedEncodingException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | |
| | | xpOperationsUser.setNickName(exportOperationsUserVo.getNickName()); |
| | | xpOperationsUser.setUniqueNumber(exportOperationsUserVo.getUniqueNumber()); |
| | | xpOperationsUser.setAvatar(exportOperationsUserVo.getAvatar()); |
| | | boolean isPhone = PhoneUtil.isPhone(exportOperationsUserVo.getPhoneNumber()); |
| | | boolean isPhone = PhoneUtil.isMobile(exportOperationsUserVo.getPhoneNumber()); |
| | | if (!isPhone) { |
| | | throw new ServiceException("以下帐号格式不正确:"+exportOperationsUserVo.getPhoneNumber(), I18nKeyConstant.ACCOUNT_FORMAT_ERROR); |
| | | throw new ServiceException("以下帐号格式不正确:", I18nKeyConstant.ACCOUNT_FORMAT_ERROR,new Object[]{exportOperationsUserVo.getPhoneNumber()}); |
| | | } |
| | | // 判断账号是否已存在 |
| | | long count = this.count(Wrappers.lambdaQuery(XpOperationsUser.class) |
| | | .eq(XpOperationsUser::getPhoneNumber, exportOperationsUserVo.getPhoneNumber())); |
| | | if (count > 0) { |
| | | throw new ServiceException("以下帐号已存在:", I18nKeyConstant.ACCOUNT_EXIST,new Object[]{exportOperationsUserVo.getPhoneNumber()}); |
| | | } |
| | | xpOperationsUser.setPhoneNumber(exportOperationsUserVo.getPhoneNumber()); |
| | | xpOperationsUser.setPassword(SecurityUtils.encryptPassword("a123456")); |
| | |
| | | return vo; |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | |
| | | @Override |
| | | public List<XpOperationsUser> getByPhoneNumber(String phoneNumber) { |
| | | if (StringUtils.isBlank(phoneNumber)) { |
| | | return Collections.emptyList(); |
| | | } |
| | | return lambdaQuery().like(XpOperationsUser::getPhoneNumber, phoneNumber).list(); |
| | | } |
| | | |
| | | @Override |
| | | public List<XpOperationsUserWithRoleVO> pageListByIds(OptionalUsersPageListQuery q) { |
| | | return baseMapper.pageListByIds(q); |
| | | } |
| | | } |