From 03b3b72756f2933f408da17a9c677b415f9dc679 Mon Sep 17 00:00:00 2001
From: tangzy <tangzy123456>
Date: Fri, 13 Aug 2021 20:46:50 +0800
Subject: [PATCH] 1.许可审批

---
 src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java |   69 ++++++++++++++++++++++++++++++----
 1 files changed, 61 insertions(+), 8 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 a83eccc..b42672c 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
@@ -43,6 +43,7 @@
 import org.springblade.modules.system.entity.*;
 import org.springblade.modules.system.excel.UserExcel;
 import org.springblade.modules.system.mapper.UserMapper;
+import org.springblade.modules.system.node.TreeNode;
 import org.springblade.modules.system.service.IRoleService;
 import org.springblade.modules.system.service.IUserDeptService;
 import org.springblade.modules.system.service.IUserOauthService;
@@ -52,10 +53,7 @@
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
 
 import static org.springblade.common.constant.CommonConstant.DEFAULT_PARAM_PASSWORD;
 
@@ -97,10 +95,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()));
+//		}
 		return save(user) && submitUserDept(user);
 	}
 
@@ -304,7 +302,22 @@
 			if (!AuthUtil.isAdministrator() || StringUtil.isBlank(user.getTenantId())) {
 				user.setTenantId(AuthUtil.getTenantId());
 			}
+			if (null != userExcel.getStatus() && userExcel.getStatus() != "") {
+				if (userExcel.getStatus().equals("在职")) {
+					user.setStatus(1);
+				} else {
+					user.setStatus(2);
+				}
+			}
+			if (userExcel.getSex().equals("男性")) {
+				user.setSex(1);
+			} else {
+				user.setSex(2);
+			}
 			user.setRoleId("1412226235153731586");
+			String deptname = user.getDeptId();
+			String id = userDeptService.selectIn(deptname);
+			user.setDeptId(id);
 			//获取默认密码配置
 			String initPassword = ParamCache.getValue(DEFAULT_PARAM_PASSWORD);
 			user.setPassword(initPassword);
@@ -407,6 +420,7 @@
 
 	/**
 	 * 通过 身份证号查询用户信息
+	 *
 	 * @param idCardNo 身份证号
 	 * @return
 	 */
@@ -433,6 +447,7 @@
 
 	/**
 	 * 保安员列表,帅选无保安证
+	 *
 	 * @param page
 	 * @param user
 	 * @param deptId
@@ -444,4 +459,42 @@
 		List<Long> deptIdList = SysCache.getDeptChildIds(deptId);
 		return baseMapper.selectUserPageSecurityApply(page, user, null, tenantId);
 	}
+
+	/**
+	 * 保安员列表树 安员列表树,帅选无保安证,下拉tree
+	 *
+	 * @param user 用户信息
+	 * @return
+	 */
+	@Override
+	public List<TreeNode> getSecurityApplyTree(UserVO user) {
+		Map<Long, TreeNode> map = baseMapper.getSecurityApplyTree(user);
+		List<TreeNode> tree = new ArrayList<>();
+		if (map.size() > 1) {
+			map.forEach((id, treeNode) -> {
+				if (map.containsKey(treeNode.getParentId())) {
+					map.get(treeNode.getParentId()).getChildren().add(treeNode);
+				} else {
+					tree.add(treeNode);
+				}
+			});
+		}
+		return tree;
+	}
+
+	@Override
+	public List<Map<Object, Object>> selectInr(String deptid) {
+		return baseMapper.selectInr(deptid);
+	}
+
+	/**
+	 * 查询当前年份已有的保安证编号
+	 *
+	 * @param pre 前缀
+	 * @return
+	 */
+	@Override
+	public int getSecurityPaperCount(String pre) {
+		return baseMapper.getSecurityPaperCount(pre);
+	}
 }

--
Gitblit v1.9.3