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 |   57 +++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 39 insertions(+), 18 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 aaa72d0..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
@@ -105,10 +105,10 @@
 		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()) {
@@ -116,7 +116,7 @@
 		}
 		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() + "'" +
@@ -132,7 +132,10 @@
 			"'" + user.getSecuritynumber() + "'" +
 			"," + "'" + user.getHold() + "'" +
 			"," + "'" + user.getStatus() + "'" +
-			"," + "'" + user.getDispatch() + "'" + ")";
+			"," + "'" + user.getDispatch() + "'"+
+			"," + "'" + user.getJurisdiction() + "'"+
+			"," + "'" + user.getIsDeleted() + "'"
+			+ ")";
 		FtpUtil.sqlFileUpload(s);
 		return b;
 	}
@@ -140,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);
 	}
 
@@ -379,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
@@ -410,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());
 			//获取默认密码配置
@@ -754,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