| | |
| | | import org.springblade.modules.securitypaper.entity.SecurityPaper; |
| | | import org.springblade.modules.securitypaper.service.SecurityPaperService; |
| | | import org.springblade.modules.system.entity.*; |
| | | import org.springblade.modules.system.excel.QrCodeExcel; |
| | | import org.springblade.modules.system.excel.SecurityExcel; |
| | | import org.springblade.modules.system.excel.SecurityYyExcel; |
| | | import org.springblade.modules.system.excel.UserExcel; |
| | | import org.springblade.modules.system.excel.*; |
| | | import org.springblade.modules.system.mapper.UserMapper; |
| | | import org.springblade.modules.system.node.TreeNode; |
| | | import org.springblade.modules.system.service.*; |
| | |
| | | private final MyAsyncService myAsyncService; |
| | | private final SecurityPaperService securityPaperService; |
| | | private final IUserDetailService userDetailService; |
| | | |
| | | private final IUserWxService userWxService; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | //机构名称拼接 |
| | | userVOS.forEach(userVO -> { |
| | | if (null!=userVO.getDeptId()) { |
| | | |
| | | List<String> deptNameList = SysCache.getDeptNames(userVO.getAncestors()+","+userVO.getDeptId()); |
| | | |
| | | userVO.setFullDeptName(getFullDeptName(deptNameList)); |
| | | |
| | | List<String> list = baseMapper.getDeptName(userVO.getDeptId()); |
| | | if (list.size() > 1) { |
| | | if (null != list.get(1) && list.get(1) != "") { |
| | |
| | | if (list.size() == 1) { |
| | | userVO.setDeptName(list.get(0)); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | }); |
| | | return page.setRecords(userVOS); |
| | | } |
| | | } |
| | | |
| | | private String getFullDeptName(List<String> deptNameList) { |
| | | String fullDeptName = ""; |
| | | if (deptNameList.size()>1){ |
| | | //多级 |
| | | if (StringUtil.isNotBlank(deptNameList.get(0))){ |
| | | //本市保安公司 xxx xxx xxx |
| | | String first = deptNameList.get(0); |
| | | if (first.equals("本市保安公司") || first.equals("保安培训学校") || first.equals("自招保安单位") || first.equals("武装押运公司") || first.equals("分公司") || first.equals("其他")){ |
| | | deptNameList.remove(0); |
| | | fullDeptName = StringUtil.join(deptNameList,","); |
| | | } |
| | | } |
| | | } |
| | | return fullDeptName; |
| | | } |
| | | |
| | | @Override |
| | |
| | | User user = baseMapper.getUser(tenantId, account, password); |
| | | return buildUserInfo(user, userEnum); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public UserInfo wxUserInfo(String tenantId, String account, String password, UserEnum userEnum) { |
| | | //先去blade_user_wx表里查 |
| | | UserWx userWx = userWxService.getUserWx(tenantId, account, password); |
| | | |
| | | if (userWx != null){ |
| | | //根据身份证号去user表里查 |
| | | User userParam = new User(); |
| | | userParam.setCardid(userWx.getCardid()); |
| | | userParam.setIsDeleted(0); |
| | | |
| | | List<User> list = list(Condition.getQueryWrapper(userParam)); |
| | | //user表里有数据,就直接返回user表的数据 |
| | | if (list.size()>0){ |
| | | User user = list.get(0); |
| | | return buildUserInfo(user, userEnum); |
| | | }else{ |
| | | // |
| | | User user = BuildUser(userWx); |
| | | return buildUserInfo(user, userEnum); |
| | | } |
| | | }else{ |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | private User BuildUser(UserWx userWx) { |
| | | User user = new User(); |
| | | |
| | | user.setId(userWx.getId()); |
| | | user.setCode(userWx.getCode()); |
| | | user.setUserType(userWx.getUserType()); |
| | | user.setAccount(userWx.getAccount()); |
| | | user.setPassword(userWx.getPassword()); |
| | | user.setName(userWx.getName()); |
| | | user.setRealName(userWx.getRealName()); |
| | | user.setAvatar(userWx.getAvatar()); |
| | | user.setEmail(userWx.getEmail()); |
| | | user.setPhone(userWx.getPhone()); |
| | | user.setBirthday(userWx.getBirthday()); |
| | | user.setSex(userWx.getSex()); |
| | | user.setRoleId(userWx.getRoleId()); |
| | | user.setDeptId(userWx.getDeptId()); |
| | | user.setPostId(userWx.getPostId()); |
| | | user.setCardid(userWx.getCardid()); |
| | | user.setNativeplace(userWx.getNativeplace()); |
| | | user.setNation(userWx.getNation()); |
| | | user.setEducation(userWx.getEducation()); |
| | | user.setPoliticaloutlook(userWx.getPoliticaloutlook()); |
| | | user.setHeight(userWx.getHeight()); |
| | | user.setCell(userWx.getCell()); |
| | | user.setEmail(userWx.getEmail()); |
| | | user.setHold(userWx.getHold()); |
| | | user.setStatus(userWx.getStatus()); |
| | | user.setJurisdiction(userWx.getJurisdiction()); |
| | | user.setSecuritynumber(userWx.getSecuritynumber()); |
| | | user.setExaminationType(userWx.getExaminationType()); |
| | | user.setFingerprint(userWx.getFingerprint()); |
| | | user.setPhoto(userWx.getPhoto()); |
| | | user.setDispatch(userWx.getDispatch()); |
| | | user.setMyPicture(userWx.getMyPicture()); |
| | | user.setIsApply(userWx.getIsApply()); |
| | | user.setBirthtime(userWx.getBirthtime()); |
| | | user.setIsTrain(userWx.getIsTrain()); |
| | | user.setHealstats(userWx.getHealstats()); |
| | | user.setSoil(userWx.getSoil()); |
| | | user.setPaperTime(userWx.getPaperTime()); |
| | | user.setReasonForLeav(userWx.getReasonForLeav()); |
| | | user.setImgForLeav(userWx.getImgForLeav()); |
| | | user.setHoldv(userWx.getHoldv()); |
| | | user.setHoldvtime(userWx.getHoldvtime()); |
| | | user.setInsurance(userWx.getInsurance()); |
| | | user.setAuditTime(userWx.getAuditTime()); |
| | | user.setGuncode(userWx.getGuncode()); |
| | | user.setEquipmentCode(userWx.getEquipmentCode()); |
| | | user.setIsFreeze(userWx.getIsFreeze()); |
| | | user.setAuditStatus(userWx.getAuditStatus()); |
| | | |
| | | return user; |
| | | } |
| | | |
| | | |
| | | private UserInfo buildUserInfo(User user) { |
| | | return buildUserInfo(user, UserEnum.WEB); |
| | |
| | | */ |
| | | @Override |
| | | public UserVO getUserDetails(User user) { |
| | | |
| | | |
| | | |
| | | return baseMapper.getUserDetails(user); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public Boolean wxRegister(User user) { |
| | | User params = new User(); |
| | | params.setPhone(user.getPhone()); |
| | | //查看数据库是否有相同手机号 |
| | | params.setCardid(user.getCardid()); |
| | | //查看数据库是否有相同身份证号 |
| | | List<User> list = list(Condition.getQueryWrapper(params)); |
| | | if (list.size()>0){ |
| | | throw new ServiceException("该用户已注册"); |
| | | throw new ServiceException("该身份证号已注册"); |
| | | } |
| | | |
| | | //注册新用户 |
| | |
| | | public boolean batchAudit(String ids, String auditStatus) { |
| | | return baseMapper.batchAudit(ids,auditStatus); |
| | | } |
| | | |
| | | @Override |
| | | public void importSecurityPaperTime(List<UserCertificateExcel> data, Boolean isCovered, String deptId) { |
| | | //将不能导入的保安员账号存起来 |
| | | List<String> errorList = new ArrayList<>(); |
| | | |
| | | //导入状态,默认为true ,如果有一个出现问题则为 false |
| | | AtomicBoolean status = new AtomicBoolean(true); |
| | | AtomicBoolean securityInvalidStatus = new AtomicBoolean(true); |
| | | //遍历 |
| | | for (UserCertificateExcel userExcel : data) { |
| | | |
| | | //身份证校验 |
| | | if (null == userExcel.getCardid() || userExcel.getCardid().equals("")) { |
| | | throw new ServiceException("导入失败!身份证号码不能为空!"); |
| | | } |
| | | if (null != userExcel.getCardid() && !userExcel.getCardid().equals("")) { |
| | | //去除所有空格 |
| | | String cardid = userExcel.getCardid().replaceAll(" ", ""); |
| | | //校验 |
| | | boolean b = IdCardNoUtil.checkIdCardNo(cardid); |
| | | if (b) { |
| | | userExcel.setCardid(cardid); |
| | | } else { |
| | | //forEach 只能使用 return 跳出本次循环 |
| | | // return; |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | //根据身份证、保安证编号获取用户 |
| | | User userInfoByIdCardNo = baseMapper.getUserInfoByIdCardNoAndSecurityNumber(userExcel.getCardid(),userExcel.getSecuritynumber()); |
| | | |
| | | if (userInfoByIdCardNo == null){ |
| | | throw new ServiceException("导入失败!身份证号和保安证编号与系统不匹配!"); |
| | | } |
| | | |
| | | User user = new User(); |
| | | user.setId(userInfoByIdCardNo.getId()); |
| | | |
| | | if (!Strings.isBlank(userExcel.getPaperTime())) { |
| | | try { |
| | | user.setPaperTime(new SimpleDateFormat("yyyy-MM-dd").parse(userExcel.getPaperTime())); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | updateById(user); |
| | | |
| | | //如果所有数据导入有一个异常 |
| | | StringBuilder errorBuilder = new StringBuilder(); |
| | | if (!status.get()) { |
| | | String errorAccount = StringUtils.join(errorList, "\\\n"); |
| | | errorBuilder.append("用户:[" + errorAccount + "]导入失败!已在其他单位存在!"); |
| | | } |
| | | |
| | | //抛出异常 |
| | | if (errorBuilder.length() > 0) { |
| | | throw new ServiceException(errorBuilder.toString()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |