From 345d17cf82e1bbc1fbfbeec10193c2bed59cd674 Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Mon, 27 Sep 2021 22:21:21 +0800
Subject: [PATCH] 注册登录,车辆,装备,枪支,招聘,培训考试修改
---
src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java | 118 ++++++++++++++++++++++++++++++++++++++--------------------
1 files changed, 77 insertions(+), 41 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 c1fa1d7..7b9fe05 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
@@ -61,6 +61,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import java.text.SimpleDateFormat;
import java.util.*;
import static org.springblade.common.constant.CommonConstant.DEFAULT_PARAM_PASSWORD;
@@ -104,13 +105,18 @@
if (Func.isNotEmpty(user.getPassword())) {
user.setPassword(DigestUtil.encrypt(user.getPassword()));
}
-// Integer userCount = baseMapper.selectCount(Wrappers.<User>query().lambda().eq(User::getTenantId, tenantId).eq(User::getAccount, user.getAccount()));
-// if (userCount > 0 && Func.isEmpty(user.getId())) {
-// throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount()));
-// }
+ Integer userCount = baseMapper.selectCount(Wrappers.<User>query().lambda().eq(User::getTenantId, tenantId).eq(User::getAccount, user.getAccount()));
+ if (userCount > 0 && Func.isEmpty(user.getId())) {
+ throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount()));
+ }
boolean b = save(user) && submitUserDept(user);
+ String rtime = null;
+ if (null != user.getRtime()) {
+ rtime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user.getRtime());
+ }
+ 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) " +
+ "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() + "'" +
@@ -126,7 +132,10 @@
"'" + user.getSecuritynumber() + "'" +
"," + "'" + user.getHold() + "'" +
"," + "'" + user.getStatus() + "'" +
- "," + "'" + user.getDispatch() + "'" + ")";
+ "," + "'" + user.getDispatch() + "'"+
+ "," + "'" + user.getJurisdiction() + "'"+
+ "," + "'" + user.getIsDeleted() + "'"
+ + ")";
FtpUtil.sqlFileUpload(s);
return b;
}
@@ -134,16 +143,16 @@
@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()));
- }
+// 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);
}
@@ -183,32 +192,41 @@
public IPage<UserVO> selectUserPage(IPage<UserVO> page, User user, Long deptId, String tenantId) {
List<Long> deptIdList = SysCache.getDeptChildIds(deptId);
List<UserVO> users = baseMapper.selectUserPage(page, user, deptIdList, tenantId);
- //遍历获取部门名称,角色名称
- users.forEach(userVO -> {
- //查询当前部门名称及父级部门名称
- List<String> list = baseMapper.getDeptName(userVO.getDeptId());
- if (list.size()>1){
- if (null!=list.get(1) && list.get(1)!=""){
- userVO.setDeptName(list.get(1)+","+list.get(0));
- }else {
- userVO.setDeptName(list.get(0));
+ if(users.size()>0){
+ //遍历获取部门名称,角色名称
+ users.forEach(userVO -> {
+ //查询当前部门名称及父级部门名称
+ if (null!=userVO.getDeptId()) {
+ List<String> list = baseMapper.getDeptName(userVO.getDeptId());
+ if (list.size() > 1) {
+ if (null != list.get(1) && list.get(1) != "") {
+ userVO.setDeptName(list.get(1) + "," + list.get(0));
+ } else {
+ userVO.setDeptName(list.get(0));
+ }
+ }
+ if (list.size() == 1) {
+ userVO.setDeptName(list.get(0));
+ }
}
- }
- if (list.size()==1){
- userVO.setDeptName(list.get(0));
- }
- //查询角色名称
- List<String> asList = Arrays.asList(userVO.getRoleId().split(","));
- StringBuilder builder = new StringBuilder();
- asList.forEach(roleIs ->{
- Role role = roleService.getById(roleIs);
- if (null!=role){
- builder.append(role.getRoleName()+",");
+ //查询角色名称
+ if (null!=userVO.getRoleId()) {
+ List<String> asList = Arrays.asList(userVO.getRoleId().split(","));
+ StringBuilder builder = new StringBuilder();
+ asList.forEach(roleIs -> {
+ Role role = roleService.getById(roleIs);
+ if (null != role) {
+ builder.append(role.getRoleName() + ",");
+ }
+ });
+ String substringRoleName = null;
+ if (builder.toString().length() > 0) {
+ substringRoleName = builder.toString().substring(0, builder.toString().length() - 1);
+ }
+ userVO.setRoleName(substringRoleName);
}
});
- String substringRoleName = builder.toString().substring(0, builder.toString().length() - 1);
- userVO.setRoleName(substringRoleName);
- });
+ }
return page.setRecords(users);
}
@@ -364,7 +382,7 @@
@Override
@Transactional(rollbackFor = Exception.class)
- public void importUser(List<UserExcel> data, Boolean isCovered) {
+ public void importUser(List<UserExcel> data, Boolean isCovered,String deptId) {
data.forEach(userExcel -> {
User user = Objects.requireNonNull(BeanUtil.copy(userExcel, User.class));
// 设置租户ID
@@ -395,7 +413,15 @@
}
}
//设置部门id
- user.setDeptId(userDeptService.selectIn(user.getDeptId()));
+ String deptIds = userDeptService.selectIn(user.getDeptId());
+ if (null!=deptIds && !deptIds.equals("")) {
+ if (null != deptId && !deptId.equals("")) {
+ if (!deptId.equals(deptIds)) {
+ throw new ServiceException("不能导入不是本公司的保安员数据!");
+ }
+ }
+ user.setDeptId(deptIds);
+ }
//设置账号
user.setAccount(user.getCardid());
//获取默认密码配置
@@ -739,4 +765,14 @@
public Integer selectCount(String account) {
return baseMapper.selectCountAccount(account);
}
+
+ /**
+ * 查询用户表中未删除,未离职的用户信息
+ * @param username
+ * @return
+ */
+ @Override
+ public User getUserInfo(String username) {
+ return baseMapper.getUserInfo(username);
+ }
}
--
Gitblit v1.9.3