| | |
| | | import com.google.zxing.WriterException; |
| | | import lombok.AllArgsConstructor; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.logging.log4j.util.Strings; |
| | | import org.springblade.common.cache.SysCache; |
| | | import org.springblade.common.config.QrcodeConfig; |
| | | import org.springblade.common.constant.AgeUtil; |
| | |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLEncoder; |
| | | import java.text.DecimalFormat; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.concurrent.atomic.AtomicBoolean; |
| | |
| | | } |
| | | boolean b = save(user) && submitUserDept(user); |
| | | user.setIsDeleted(0); |
| | | String s = "insert into blade_user(id,tenant_id,account,password,real_name,email,phone,sex,role_id,dept_id,cardid,nativePlace,nation," + |
| | | "politicaloutlook,healstats,height,address,registered,securitynumber,hold,status,dispatch,jurisdiction,is_deleted) " + |
| | | "values(" + "'" + user.getId() + "'" + "," + "'" + user.getTenantId() + "'" + "," + "'" + user.getAccount() + "'" + "," + |
| | | "'" + user.getPassword() + "'" + "," + "'" + user.getRealName() + "'" + "," + |
| | | "'" + user.getEmail() + "'" + "," + "'" + user.getPhone() + "'" + "," + "'" + user.getSex() + "'" + "," + "'" + user.getRoleId() + "'" + |
| | | "," + "'" + user.getDeptId() + "'" + |
| | | "," + "'" + user.getCardid() + "'" + |
| | | "," + "'" + user.getNativeplace() + "'" + |
| | | "," + "'" + user.getNation() + "'" + |
| | | "," + "'" + user.getPoliticaloutlook() + "'" + |
| | | "," + "'" + user.getHealstats() + "'" |
| | | + "," + "'" + user.getHeight() + "'" + |
| | | "," + "'" + user.getAddress() + "'" + |
| | | "," + "'" + user.getRegistered() + "'" + "," + |
| | | "'" + user.getSecuritynumber() + "'" + |
| | | "," + "'" + user.getHold() + "'" + |
| | | "," + "'" + user.getStatus() + "'" + |
| | | "," + "'" + user.getDispatch() + "'"+ |
| | | "," + "'" + user.getJurisdiction() + "'"+ |
| | | "," + "'" + user.getIsDeleted() + "'" |
| | | + ")"; |
| | | //FtpUtil.sqlFileUpload(s); |
| | | myAsyncService.dataSync(s); |
| | | return b; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean updateUser(User user) { |
| | | // String tenantId = user.getTenantId(); |
| | | // Integer userCount = baseMapper.selectCount( |
| | | // Wrappers.<User>query().lambda() |
| | | // .eq(User::getTenantId, tenantId) |
| | | // .eq(User::getAccount, user.getAccount()) |
| | | // .notIn(User::getId, user.getId()) |
| | | // ); |
| | | // if (userCount > 0) { |
| | | // throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount())); |
| | | // } |
| | | return updateUserInfo(user) && submitUserDept(user); |
| | | } |
| | | |
| | |
| | | List<UserVO> userVOS = baseMapper.selectUserPagesByAge(page, user); |
| | | //机构名称拼接 |
| | | userVOS.forEach(userVO -> { |
| | | // if (null != userVO.getCardid() && userVO.getCardid() != "") { |
| | | // userVO.setAge(AgeUtil.idCardToAge(userVO.getCardid())); |
| | | // } else { |
| | | // userVO.setAge(null); |
| | | // } |
| | | if (null!=userVO.getDeptId()) { |
| | | List<String> list = baseMapper.getDeptName(userVO.getDeptId()); |
| | | if (list.size() > 1) { |
| | |
| | | List<UserVO> userVOS = baseMapper.selectUserPages(page, user); |
| | | //机构名称拼接 |
| | | userVOS.forEach(userVO -> { |
| | | // if (null != userVO.getCardid() && userVO.getCardid() != "") { |
| | | // userVO.setAge(AgeUtil.idCardToAge(userVO.getCardid())); |
| | | // } else { |
| | | // userVO.setAge(null); |
| | | // } |
| | | if (null!=userVO.getDeptId()) { |
| | | List<String> list = baseMapper.getDeptName(userVO.getDeptId()); |
| | | if (list.size() > 1) { |
| | |
| | | throw new ServiceException("导入失败!身份证号码不能为空!"); |
| | | } |
| | | //身份证住址校验 |
| | | if (null==user.getRegistered() || user.getRegistered().equals("")){ |
| | | throw new ServiceException("导入失败!身份证住址不能为空!"); |
| | | if (null==userExcel.getPermanentResidenceAddress() || userExcel.getPermanentResidenceAddress().equals("")){ |
| | | throw new ServiceException("导入失败!户籍地址不能为空!"); |
| | | } |
| | | if (null!=user.getCardid() && !user.getCardid().equals("")){ |
| | | //去除所有空格 |
| | |
| | | //默认在职 |
| | | user.setStatus(1); |
| | | user.setIsDeleted(0); |
| | | user.setHold("2"); |
| | | securityNumberCheck(securityInvalidList, securityInvalidStatus, user, userExcel.getSecuritynumber(), userExcel.getCardid()); |
| | | //分配保安角色 |
| | | Role role = new Role(); |
| | | role.setRoleAlias("保安"); |
| | |
| | | detailEntity.setMemberOfFamily(userExcel.getMemberOfFamily()); |
| | | detailEntity.setWorkExperience(userExcel.getWorkExperience()); |
| | | detailEntity.setPermanentResidenceAddress(userExcel.getPermanentResidenceAddress()); |
| | | if (!Strings.isBlank(userExcel.getMarriageStatus())) { |
| | | detailEntity.setMarriageStatus(Integer.parseInt(userExcel.getMarriageStatus())); |
| | | } |
| | | if (!Strings.isBlank(userExcel.getSignLevel())) { |
| | | detailEntity.setSignLevel(Integer.parseInt(userExcel.getSignLevel())); |
| | | } |
| | | detailEntity.setUnitName(userExcel.getUnitName()); |
| | | detailEntity.setPermanentResidenceAddress(userExcel.getPermanentResidenceAddress()); |
| | | detailEntity.setDwellAddress(userExcel.getDwellAddress()); |
| | | detailEntity.setAcceptancePoliceUnit(userExcel.getAcceptancePoliceUnit()); |
| | | detailEntity.setAcceptancePerson(userExcel.getAcceptancePerson()); |
| | | if (!Strings.isBlank(userExcel.getAcceptanceTime())){ |
| | | try { |
| | | detailEntity.setAcceptanceTime(new SimpleDateFormat("yyyy/MM/dd").parse(userExcel.getAcceptanceTime())); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | userDetailService.save(detailEntity); |
| | | } |
| | | //加入集合 |
| | |
| | | // return; |
| | | continue; |
| | | }else { |
| | | //如果是一致,则更新用户数据 |
| | | if (null!=userExcel.getRegistered()){ |
| | | user2.setRegistered(userExcel.getRegistered()); |
| | | }else { |
| | | user2.setRegistered(""); |
| | | } |
| | | |
| | | // 住址 |
| | | if (null!=userExcel.getAddress()){ |
| | | user2.setAddress(userExcel.getAddress()); |
| | | }else { |
| | | user2.setAddress(""); |
| | | } |
| | | |
| | | // 学历 |
| | | if (null!=userExcel.getEducation()){ |
| | | user2.setEducation(user.getEducation()); |
| | | }else { |
| | | user2.setEducation(""); |
| | | } |
| | | |
| | | // 从业单位 |
| | | if (null!=userExcel.getUnitName()){ |
| | | user2.setUnitName(userExcel.getUnitName()); |
| | | }else { |
| | | user2.setUnitName(""); |
| | | } |
| | | |
| | | // 政治面貌 |
| | |
| | | one.setMemberOfFamily(userExcel.getMemberOfFamily()); |
| | | one.setWorkExperience(userExcel.getWorkExperience()); |
| | | one.setPermanentResidenceAddress(userExcel.getPermanentResidenceAddress()); |
| | | if (!Strings.isBlank(userExcel.getMarriageStatus())) { |
| | | one.setMarriageStatus(Integer.parseInt(userExcel.getMarriageStatus())); |
| | | } |
| | | if (!Strings.isBlank(userExcel.getSignLevel())) { |
| | | one.setSignLevel(Integer.parseInt(userExcel.getSignLevel())); |
| | | } |
| | | one.setUnitName(userExcel.getUnitName()); |
| | | one.setPermanentResidenceAddress(userExcel.getPermanentResidenceAddress()); |
| | | one.setDwellAddress(userExcel.getDwellAddress()); |
| | | one.setAcceptancePoliceUnit(userExcel.getAcceptancePoliceUnit()); |
| | | one.setAcceptancePerson(userExcel.getAcceptancePerson()); |
| | | if (!Strings.isBlank(userExcel.getAcceptanceTime())){ |
| | | try { |
| | | one.setAcceptanceTime(new SimpleDateFormat("yyyy/MM/dd").parse(userExcel.getAcceptanceTime())); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | userDetailService.updateById(one); |
| | | }else { |
| | | UserDetailEntity detailEntity = new UserDetailEntity(); |
| | |
| | | detailEntity.setMemberOfFamily(userExcel.getMemberOfFamily()); |
| | | detailEntity.setWorkExperience(userExcel.getWorkExperience()); |
| | | detailEntity.setPermanentResidenceAddress(userExcel.getPermanentResidenceAddress()); |
| | | if (!Strings.isBlank(userExcel.getMarriageStatus())) { |
| | | detailEntity.setMarriageStatus(Integer.parseInt(userExcel.getMarriageStatus())); |
| | | } |
| | | if (!Strings.isBlank(userExcel.getSignLevel())) { |
| | | detailEntity.setSignLevel(Integer.parseInt(userExcel.getSignLevel())); |
| | | } |
| | | detailEntity.setUnitName(userExcel.getUnitName()); |
| | | detailEntity.setPermanentResidenceAddress(userExcel.getPermanentResidenceAddress()); |
| | | detailEntity.setDwellAddress(userExcel.getDwellAddress()); |
| | | detailEntity.setAcceptancePoliceUnit(userExcel.getAcceptancePoliceUnit()); |
| | | detailEntity.setAcceptancePerson(userExcel.getAcceptancePerson()); |
| | | if (!Strings.isBlank(userExcel.getAcceptanceTime())){ |
| | | try { |
| | | detailEntity.setAcceptanceTime(new SimpleDateFormat("yyyy/MM/dd").parse(userExcel.getAcceptanceTime())); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | userDetailService.save(detailEntity); |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 判断是否持证 |
| | | * @param securityInvalidList |
| | | * @param securityInvalidStatus |
| | | * @param user |
| | | * @param securitynumber |
| | | * @param cardid2 |
| | | */ |
| | | public void securityNumberCheck(List<String> securityInvalidList, AtomicBoolean securityInvalidStatus, User user, String securitynumber, String cardid2) { |
| | | //判断是否持证 |
| | | if (null != securitynumber && securitynumber != "") { |
| | | user.setHold("1"); |
| | | //校验保安员证编号是否合规 |
| | | SecurityPaper securityPaper = new SecurityPaper(); |
| | | securityPaper.setIdCardNo(cardid2); |
| | | List<SecurityPaper> securityPaperList = securityPaperService.list(Condition.getQueryWrapper(securityPaper)); |
| | | if (securityPaperList.size() > 0) { |
| | | boolean state = false; |
| | | //遍历 |
| | | for (SecurityPaper paper : securityPaperList) { |
| | | if (paper.getNumber().equals(user.getSecuritynumber())) { |
| | | state = true; |
| | | } |
| | | } |
| | | if (!state) { |
| | | user.setHold("2"); |
| | | user.setSecuritynumber(null); |
| | | securityInvalidList.add(cardid2); |
| | | securityInvalidStatus.set(false); |
| | | } |
| | | } else { |
| | | user.setHold("2"); |
| | | user.setSecuritynumber(null); |
| | | securityInvalidList.add(cardid2); |
| | | securityInvalidStatus.set(false); |
| | | } |
| | | } else { |
| | | user.setHold("2"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void importSecurityYy(List<SecurityYyExcel> data, Boolean isCovered, String deptId) { |
| | | //将不能导入的保安员账号存起来 |
| | |
| | | if (null==user.getCardid() || user.getCardid().equals("")){ |
| | | throw new ServiceException("导入失败!身份证号码不能为空!"); |
| | | } |
| | | //身份证住址校验 |
| | | if (null==user.getRegistered() || user.getRegistered().equals("")){ |
| | | throw new ServiceException("导入失败!身份证住址不能为空!"); |
| | | } |
| | | if (null!=user.getCardid() && !user.getCardid().equals("")){ |
| | | //去除所有空格 |
| | | String cardid = user.getCardid().replaceAll(" ", ""); |
| | |
| | | user.setStatus(1); |
| | | user.setIsDeleted(0); |
| | | //判断是否持证 |
| | | if (null != userExcel.getSecuritynumber() && userExcel.getSecuritynumber() != "") { |
| | | user.setHold("1"); |
| | | //校验保安员证编号是否合规 |
| | | SecurityPaper securityPaper = new SecurityPaper(); |
| | | securityPaper.setIdCardNo(userExcel.getCardid()); |
| | | List<SecurityPaper> securityPaperList = securityPaperService.list(Condition.getQueryWrapper(securityPaper)); |
| | | if (securityPaperList.size()>0){ |
| | | boolean state = false; |
| | | //遍历 |
| | | for (SecurityPaper paper : securityPaperList) { |
| | | if (paper.getNumber().equals(user.getSecuritynumber())){ |
| | | state = true; |
| | | } |
| | | } |
| | | if (!state){ |
| | | user.setHold("2"); |
| | | user.setSecuritynumber(null); |
| | | securityInvalidList.add(userExcel.getCardid()); |
| | | securityInvalidStatus.set(false); |
| | | } |
| | | }else { |
| | | user.setHold("2"); |
| | | user.setSecuritynumber(null); |
| | | securityInvalidList.add(userExcel.getCardid()); |
| | | securityInvalidStatus.set(false); |
| | | } |
| | | }else { |
| | | user.setHold("2"); |
| | | } |
| | | securityNumberCheck(securityInvalidList, securityInvalidStatus, user, userExcel.getSecuritynumber(), userExcel.getCardid()); |
| | | //分配保安角色 |
| | | Role role = new Role(); |
| | | role.setRoleAlias("保安"); |
| | |
| | | }else { |
| | | user2.setHold("2"); |
| | | } |
| | | if (null!=userExcel.getRegistered()){ |
| | | user2.setRegistered(userExcel.getRegistered()); |
| | | }else { |
| | | user2.setRegistered(""); |
| | | } |
| | | user2.setUpdateTime(new Date()); |
| | | //更新用户数据 |
| | | this.updateById(user2); |
| | |
| | | }else { |
| | | user2.setHold("2"); |
| | | } |
| | | if (null!=userExcel.getRegistered()){ |
| | | user2.setRegistered(userExcel.getRegistered()); |
| | | }else { |
| | | user2.setRegistered(""); |
| | | } |
| | | user2.setUpdateTime(new Date()); |
| | | //更新用户数据 |
| | | this.updateById(user2); |
| | | |
| | | String s1 = |
| | | "update blade_user set hold = " + "'" + user2.getHold() + "'" |
| | | + ",securitynumber = " + "'" + user2.getSecuritynumber() + "'" |
| | | + ",registered = " + "'" + user2.getRegistered() + "'" |
| | | + ",update_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user2.getUpdateTime()) + "'" |
| | | + " " + "where id = " + "'" + user2.getId() + "'"; |
| | | //FtpUtil.sqlFileUpload(s1); |
| | | myAsyncService.dataSync(s1); |
| | | } |
| | | } |
| | | }); |
| | |
| | | if (null==user.getCardid() || user.getCardid().equals("")){ |
| | | throw new ServiceException("导入失败!身份证号码不能为空!"); |
| | | } |
| | | //身份证住址校验 |
| | | if (null==user.getRegistered() || user.getRegistered().equals("")){ |
| | | throw new ServiceException("导入失败!身份证住址不能为空!"); |
| | | } |
| | | if (null!=user.getCardid() && !user.getCardid().equals("")){ |
| | | //去除所有空格 |
| | | String cardid = user.getCardid().replaceAll(" ", ""); |
| | |
| | | user.setStatus(1); |
| | | user.setIsDeleted(0); |
| | | user.setHold("2"); |
| | | //判断是否持证 |
| | | // if (null != userExcel.getSecuritynumber() && userExcel.getSecuritynumber() != "") { |
| | | // user.setHold("1"); |
| | | // //校验保安员证编号是否合规 |
| | | // SecurityPaper securityPaper = new SecurityPaper(); |
| | | // securityPaper.setIdCardNo(userExcel.getCardid()); |
| | | // List<SecurityPaper> securityPaperList = securityPaperService.list(Condition.getQueryWrapper(securityPaper)); |
| | | // if (securityPaperList.size()>0){ |
| | | // boolean state = false; |
| | | // //遍历 |
| | | // for (SecurityPaper paper : securityPaperList) { |
| | | // if (paper.getNumber().equals(user.getSecuritynumber())){ |
| | | // state = true; |
| | | // } |
| | | // } |
| | | // if (!state){ |
| | | // user.setHold("2"); |
| | | // user.setSecuritynumber(null); |
| | | // securityInvalidList.add(userExcel.getCardid()); |
| | | // securityInvalidStatus.set(false); |
| | | // } |
| | | // }else { |
| | | // user.setHold("2"); |
| | | // user.setSecuritynumber(null); |
| | | // securityInvalidList.add(userExcel.getCardid()); |
| | | // securityInvalidStatus.set(false); |
| | | // } |
| | | // }else { |
| | | // //创建保安证编号 |
| | | // user.setHold("1"); |
| | | // //去生成保安证编号 |
| | | // String pre = SecurityPaperUtil.getSecurityPaper(); |
| | | // //查询当前年份已有的保安证编号 |
| | | // int max = this.getSecurityPaperCount(pre); |
| | | // String result = null; |
| | | // if (max == 0) { |
| | | // result = pre + "00001"; |
| | | // } else { |
| | | // //格式化 |
| | | // DecimalFormat decimalFormat = new DecimalFormat("00000"); |
| | | // max++; |
| | | // result = pre + (decimalFormat.format(max)); |
| | | // } |
| | | // user.setSecuritynumber(result); |
| | | // |
| | | // //生成保安证的同时向保安证管理表中插入一条数据 |
| | | // SecurityPaper securityPaper = new SecurityPaper(); |
| | | // securityPaper.setNumber(result); |
| | | // securityPaper.setCreateTime(new Date()); |
| | | // securityPaper.setIdCardNo(user.getCardid()); |
| | | // securityPaper.setPeopleName(user.getRealName()); |
| | | // securityPaper.setSource(3); |
| | | // //新增保安员证信息 |
| | | // securityPaperService.save(securityPaper); |
| | | // } |
| | | //分配保安角色 |
| | | Role role = new Role(); |
| | | role.setRoleAlias("保安"); |
| | |
| | | continue; |
| | | }else { |
| | | //如果是一致,则更新用户数据 |
| | | //判断是否持证 |
| | | // if (null != userExcel.getSecuritynumber() && userExcel.getSecuritynumber() != "") { |
| | | // user2.setHold("1"); |
| | | // user2.setSecuritynumber(user.getSecuritynumber()); |
| | | // //校验保安员证编号是否合规 |
| | | // SecurityPaper securityPaper = new SecurityPaper(); |
| | | // securityPaper.setIdCardNo(userExcel.getCardid()); |
| | | // List<SecurityPaper> securityPaperList = securityPaperService.list(Condition.getQueryWrapper(securityPaper)); |
| | | // if (securityPaperList.size()>0){ |
| | | // boolean state = false; |
| | | // //遍历 |
| | | // for (SecurityPaper paper : securityPaperList) { |
| | | // if (paper.getNumber().equals(user.getSecuritynumber())){ |
| | | // state = true; |
| | | // } |
| | | // } |
| | | // if (!state){ |
| | | // user2.setHold("2"); |
| | | // user2.setSecuritynumber(null); |
| | | // securityInvalidList.add(userExcel.getCardid()); |
| | | // securityInvalidStatus.set(false); |
| | | // } |
| | | // }else { |
| | | // user2.setHold("2"); |
| | | // user2.setSecuritynumber(null); |
| | | // securityInvalidList.add(userExcel.getCardid()); |
| | | // securityInvalidStatus.set(false); |
| | | // } |
| | | // }else { |
| | | // //创建保安证编号 |
| | | // user2.setHold("1"); |
| | | // //去生成保安证编号 |
| | | // String pre = SecurityPaperUtil.getSecurityPaper(); |
| | | // //查询当前年份已有的保安证编号 |
| | | // int max = this.getSecurityPaperCount(pre); |
| | | // String result = null; |
| | | // if (max == 0) { |
| | | // result = pre + "00001"; |
| | | // } else { |
| | | // //格式化 |
| | | // DecimalFormat decimalFormat = new DecimalFormat("00000"); |
| | | // max++; |
| | | // result = pre + (decimalFormat.format(max)); |
| | | // } |
| | | // user2.setSecuritynumber(result); |
| | | // |
| | | // //生成保安证的同时向保安证管理表中插入一条数据 |
| | | // SecurityPaper securityPaper = new SecurityPaper(); |
| | | // securityPaper.setNumber(result); |
| | | // securityPaper.setCreateTime(new Date()); |
| | | // securityPaper.setIdCardNo(user2.getCardid()); |
| | | // securityPaper.setPeopleName(user2.getRealName()); |
| | | // securityPaper.setSource(3); |
| | | // //新增保安员证信息 |
| | | // securityPaperService.save(securityPaper); |
| | | // } |
| | | if (null!=userExcel.getRegistered()){ |
| | | user2.setRegistered(userExcel.getRegistered()); |
| | | }else { |
| | | user2.setRegistered(""); |
| | | } |
| | | user2.setUpdateTime(new Date()); |
| | | //更新用户数据 |
| | | this.updateById(user2); |
| | | //qfqk异步推送 |
| | | // myAsyncService.updateUserByQfqk(user2); |
| | | //内网数据sql |
| | | String s1 = |
| | | "update blade_user set hold = " + "'" + user2.getHold() + "'" |
| | | + ",securitynumber = " + "'" + user2.getSecuritynumber() + "'" |
| | | + ",registered = " + "'" + user2.getRegistered() + "'" |
| | | + ",update_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user2.getUpdateTime()) + "'" |
| | | + " " + "where id = " + "'" + user2.getId() + "'"; |
| | | myAsyncService.dataSync(s1); |
| | | } |
| | | } |
| | | } |