From 19f40c8e0649ae81b3f0183a6f4c8aa6c3db39bc Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Thu, 18 Nov 2021 17:54:37 +0800
Subject: [PATCH] 证书打印信息导出修改,已过考试的,系统每天凌晨1点定时清理,标记为缺考,并生成缺考记录,保安员导入新增年龄判断,超过60岁的不能导入
---
src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java | 155 +++++++++++++++++++++++++++++----------------------
1 files changed, 87 insertions(+), 68 deletions(-)
diff --git a/src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java b/src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java
index c62718f..0653222 100644
--- a/src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java
+++ b/src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java
@@ -804,12 +804,13 @@
public void importSecurity(List<SecurityExcel> data, Boolean isCovered, String deptId) {
//将不能导入的保安员账号存起来
List<String> errorList = new ArrayList<>();
- //将需要新增的保安员信息存入集合
- List<User> insertList = new ArrayList<>();
+ //年龄不符的保安员信息存入集合
+ List<String> ageErrorList = new ArrayList<>();
//将需要更新的保安员信息存入集合
List<User> updateList = new ArrayList<>();
//导入状态,默认为true ,如果有一个出现问题则为 false
AtomicBoolean status = new AtomicBoolean(true);
+ AtomicBoolean agetStatus = new AtomicBoolean(true);
data.forEach(userExcel -> {
User user = Objects.requireNonNull(BeanUtil.copy(userExcel, User.class));
//设置部门id
@@ -847,37 +848,39 @@
user.setHold("2");
}
}
- //分配保安角色
- Role role = new Role();
- role.setRoleAlias("保安");
- Role oneRole = roleService.getOne(Condition.getQueryWrapper(role));
- user.setRoleId(oneRole.getId().toString());
+ //判断年龄,超过60岁的不入
+ if (AgeUtil.idCardToAge(user.getCardid())<60) {
+ //分配保安角色
+ Role role = new Role();
+ role.setRoleAlias("保安");
+ Role oneRole = roleService.getOne(Condition.getQueryWrapper(role));
+ user.setRoleId(oneRole.getId().toString());
- //性别
- if (null != userExcel.getSex()) {
- if (userExcel.getSex().equals("男")) {
- user.setSex(1);
+ //性别
+ if (null != userExcel.getSex()) {
+ if (userExcel.getSex().equals("男")) {
+ user.setSex(1);
+ }
+ if (userExcel.getSex().equals("女")) {
+ user.setSex(2);
+ }
}
- if (userExcel.getSex().equals("女")) {
- user.setSex(2);
- }
- }
- //设置账号
- user.setAccount(user.getCardid());
- //获取默认密码配置
- user.setPassword(user.getCardid().substring(user.getCardid().length() - 6));
- //加密
- if (Func.isNotEmpty(user.getPassword())) {
- user.setPassword(DigestUtil.encrypt(user.getPassword()));
- }
- Integer userCount = baseMapper.selectCountAccount(user.getAccount());
- if (userCount > 0 && Func.isEmpty(user.getId())) {
- throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount()));
- }
- //新增
- this.save(user);
- //内网同步
+ //设置账号
+ user.setAccount(user.getCardid());
+ //获取默认密码配置
+ user.setPassword(user.getCardid().substring(user.getCardid().length() - 6));
+ //加密
+ if (Func.isNotEmpty(user.getPassword())) {
+ user.setPassword(DigestUtil.encrypt(user.getPassword()));
+ }
+ Integer userCount = baseMapper.selectCountAccount(user.getAccount());
+ if (userCount > 0 && Func.isEmpty(user.getId())) {
+ throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount()));
+ }
+ //新增
+ this.save(user);
+ //内网同步
// String s = "insert into blade_user(" +
// "id,tenant_id,account,password,real_name,phone,sex,role_id,dept_id," +
// "cardid,nation,registered,securitynumber,hold,status,is_deleted) " +
@@ -898,41 +901,45 @@
// "," + "'" + user.getStatus() + "'" +
// "," + "'" + user.getIsDeleted() + "'"
// + ")";
- String s = "insert into blade_user(" +
- "id,tenant_id,account,password,name,real_name,avatar,email,phone,sex," +
- "role_id,dept_id,cardid,nativePlace,nation,fingerprint,education," +
- "politicaloutlook,healstats,height,address,registered," +
- "securitynumber,hold,jurisdiction,examination_type,status,is_deleted,dispatch) " +
- "values(" + "'" + user.getId() + "'" +
- "," + "'" + user.getTenantId() + "'" +
- "," + "'" + user.getAccount() + "'" +
- "," + "'" + user.getPassword() + "'" +
- "," + "'" + user.getName() + "'" +
- "," + "'" + user.getRealName() + "'" +
- "," + "'" + user.getAvatar() + "'" +
- "," + "'" + user.getEmail() + "'" +
- "," + "'" + user.getPhone() + "'" +
- "," + "'" + user.getSex() + "'" +
- "," + "'" + user.getRoleId() + "'" +
- "," + "'" + user.getDeptId() + "'" +
- "," + "'" + user.getCardid() + "'" +
- "," + "'" + user.getNativeplace() + "'" +
- "," + "'" + user.getNation() + "'" +
- "," + "'" + user.getFingerprint() + "'" +
- "," + "'" + user.getEducation() + "'" +
- "," + "'" + user.getPoliticaloutlook() + "'" +
- "," + "'" + user.getHealstats() + "'"+
- "," + "'" + user.getHeight() + "'" +
- "," + "'" + user.getAddress() + "'" +
- "," + "'" + user.getRegistered() + "'" +
- "," + "'" + user.getSecuritynumber() + "'" +
- "," + "'" + user.getHold() + "'" +
- "," + "'" + user.getJurisdiction() + "'" +
- "," + "'" + user.getExaminationType() + "'" +
- "," + "'" + user.getStatus() + "'" +
- "," + "'" + user.getIsDeleted() + "'" +
- "," + "'" + user.getDispatch() + "'" + ")";
- FtpUtil.sqlFileUpload(s);
+ String s = "insert into blade_user(" +
+ "id,tenant_id,account,password,name,real_name,avatar,email,phone,sex," +
+ "role_id,dept_id,cardid,nativePlace,nation,fingerprint,education," +
+ "politicaloutlook,healstats,height,address,registered," +
+ "securitynumber,hold,jurisdiction,examination_type,status,is_deleted,dispatch) " +
+ "values(" + "'" + user.getId() + "'" +
+ "," + "'" + user.getTenantId() + "'" +
+ "," + "'" + user.getAccount() + "'" +
+ "," + "'" + user.getPassword() + "'" +
+ "," + "'" + user.getName() + "'" +
+ "," + "'" + user.getRealName() + "'" +
+ "," + "'" + user.getAvatar() + "'" +
+ "," + "'" + user.getEmail() + "'" +
+ "," + "'" + user.getPhone() + "'" +
+ "," + "'" + user.getSex() + "'" +
+ "," + "'" + user.getRoleId() + "'" +
+ "," + "'" + user.getDeptId() + "'" +
+ "," + "'" + user.getCardid() + "'" +
+ "," + "'" + user.getNativeplace() + "'" +
+ "," + "'" + user.getNation() + "'" +
+ "," + "'" + user.getFingerprint() + "'" +
+ "," + "'" + user.getEducation() + "'" +
+ "," + "'" + user.getPoliticaloutlook() + "'" +
+ "," + "'" + user.getHealstats() + "'" +
+ "," + "'" + user.getHeight() + "'" +
+ "," + "'" + user.getAddress() + "'" +
+ "," + "'" + user.getRegistered() + "'" +
+ "," + "'" + user.getSecuritynumber() + "'" +
+ "," + "'" + user.getHold() + "'" +
+ "," + "'" + user.getJurisdiction() + "'" +
+ "," + "'" + user.getExaminationType() + "'" +
+ "," + "'" + user.getStatus() + "'" +
+ "," + "'" + user.getIsDeleted() + "'" +
+ "," + "'" + user.getDispatch() + "'" + ")";
+ FtpUtil.sqlFileUpload(s);
+ }else {
+ agetStatus.set(false);
+ ageErrorList.add(user.getCardid());
+ }
}else {
//匹配组织机构是否一致,如果不一致
if(!user2.getDeptId().equals(user.getDeptId())){
@@ -972,9 +979,21 @@
}
});
//如果所有数据导入有一个异常
- if (!status.get()){
- String errorAccount = StringUtils.join(errorList, "\\\n");
- throw new ServiceException("用户:["+errorAccount+"]导入失败!已在其他单位存在!");
+ if (!status.get() || !agetStatus.get()){
+ if (!status.get() && agetStatus.get()) {
+ String errorAccount = StringUtils.join(errorList, "\\\n");
+ throw new ServiceException("用户:[" + errorAccount + "]导入失败!已在其他单位存在!");
+ }
+ if (!agetStatus.get() && status.get()) {
+ String errorAccount = StringUtils.join(ageErrorList, "\\\n");
+ throw new ServiceException("用户:[" + errorAccount + "]导入失败!年龄不符!");
+ }
+ if (!status.get() && !agetStatus.get()) {
+ String errorAccount = StringUtils.join(errorList, "\\\n");
+ String errorAgeAccount = StringUtils.join(ageErrorList, "\\\n");
+ throw new ServiceException("用户:[" + errorAccount + "]导入失败!已在其他单位存在!"+
+ "用户:[" + errorAgeAccount + "]导入失败!年龄不符!");
+ }
}
}
--
Gitblit v1.9.3