|
@@ -429,17 +429,34 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
// 设置用户平台
|
|
// 设置用户平台
|
|
user.setUserType(String.valueOf(Func.toInt(DictCache.getKey(DictEnum.USER_TYPE, userExcel.getUserTypeName()), 1)));
|
|
user.setUserType(String.valueOf(Func.toInt(DictCache.getKey(DictEnum.USER_TYPE, userExcel.getUserTypeName()), 1)));
|
|
|
|
|
|
- //获取上级部门id
|
|
|
|
- String superiorDeptId = Func.toStrWithEmpty(SysCache.getDeptIds(AuthUtil.getTenantId(), userExcel.getDeptName().split("/")[0]), StringPool.EMPTY);
|
|
|
|
- //根据上级部门id获取所有下级部门信息
|
|
|
|
- List<Dept> deptChildIds = SysCache.getDeptChild(Long.valueOf(superiorDeptId));
|
|
|
|
- String childName = userExcel.getDeptName().split("/")[1];
|
|
|
|
- for (Dept deptChild : deptChildIds) {
|
|
|
|
- if (childName.equals(deptChild.getDeptName())) {
|
|
|
|
|
|
+ if (ObjectUtil.isEmpty(userExcel.getDeptName())) {
|
|
|
|
+ throw new ServiceException("当前机构、部门名不能为空,请填写正确的机构/部门名称(格式:总公司/子公司)再导入");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (userExcel.getDeptName().contains("/")) {
|
|
|
|
+ //获取上级部门id
|
|
|
|
+ String superiorDeptId = Func.toStrWithEmpty(SysCache.getDeptIds(AuthUtil.getTenantId(), userExcel.getDeptName().split("/")[0]), StringPool.EMPTY);
|
|
|
|
+ //根据上级部门id获取所有下级部门信息
|
|
|
|
+ if (StringUtils.isNotEmpty(superiorDeptId)) {
|
|
|
|
+ List<Dept> deptChildIds = SysCache.getDeptChild(Long.valueOf(superiorDeptId));
|
|
|
|
+ String childName = userExcel.getDeptName().split("/")[1];
|
|
|
|
+ for (Dept deptChild : deptChildIds) {
|
|
|
|
+ if (childName.equals(deptChild.getDeptName())) {
|
|
|
|
+ // 设置部门ID
|
|
|
|
+ user.setDeptId(Func.toStrWithEmpty(deptChild.getId(), StringPool.EMPTY));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ String childDeptId = Func.toStrWithEmpty(SysCache.getDeptIds(AuthUtil.getTenantId(), userExcel.getDeptName()), StringPool.EMPTY);
|
|
|
|
+ if (StringUtils.isNotEmpty(childDeptId)) {
|
|
// 设置部门ID
|
|
// 设置部门ID
|
|
- user.setDeptId(Func.toStrWithEmpty(deptChild.getId(), StringPool.EMPTY));
|
|
|
|
|
|
+ user.setDeptId(Func.toStrWithEmpty(childDeptId, StringPool.EMPTY));
|
|
|
|
+ } else {
|
|
|
|
+ throw new ServiceException("未获取到对应的部门信息,请重试");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
// 设置租户ID
|
|
// 设置租户ID
|
|
if (!AuthUtil.isAdministrator() || StringUtil.isBlank(user.getTenantId())) {
|
|
if (!AuthUtil.isAdministrator() || StringUtil.isBlank(user.getTenantId())) {
|
|
user.setTenantId(AuthUtil.getTenantId());
|
|
user.setTenantId(AuthUtil.getTenantId());
|