Commit 6497f030 authored by hkl's avatar hkl

feat:1.新需求提交

parent 305ac4e7
......@@ -173,13 +173,16 @@
t1.username,
t1.realname,
t1.user_identity,
t3.role_name
t3.role_name,
CONCAT(t1.username, ' | ', t1.realname, ' | ', t3.role_name) AS label
FROM
sys_user t1
INNER JOIN sys_user_role t2 ON t2.user_id = t1.id
INNER JOIN sys_role t3 ON t3.id = t2.role_id
WHERE
t1.del_flag = 0
AND (t1.username LIKE concat('%',#{query},'%') OR t1.realname LIKE concat('%',#{query},'%'))
<if test="query != null and query != ''">
AND (t1.username LIKE concat('%',#{query},'%') OR t1.realname LIKE concat('%',#{query},'%'))
</if>
</select>
</mapper>
package org.jeecg.modules.maintenanceWork.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
......@@ -15,7 +16,22 @@ import lombok.Data;
@ApiModel(value = "WorkBatchUserVO对象", description = "维修作业管理-派工用户")
public class WorkBatchUserVO {
private static final long serialVersionUID = 1L;
private String id;
@ApiModelProperty("用户id")
private String userId;
@ApiModelProperty("工号")
private String username;
@ApiModelProperty("名称")
private String realname;
@ApiModelProperty("用户身份")
private String userIdentity;
@ApiModelProperty("角色名称")
private String roleName;
@ApiModelProperty("显示字段")
private String label;
}
......@@ -13,6 +13,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
......@@ -604,10 +605,13 @@ public class SysUserController {
})
public Result<String> importUser(MultipartFile file) {
List<SysRole> roleList = sysRoleService.list();
List<SysUser> sysUserList = this.sysUserService.lambdaQuery()
.eq(SysUser::getDelFlag, CommonConstant.DEL_FLAG_0)
.list();
try (InputStream inputStream = file.getInputStream()) {
// 1.excel导入List<List<Object>> 中
CurrentRowHandler currentRowHandler = new CurrentRowHandler(roleList);
CurrentRowHandler currentRowHandler = new CurrentRowHandler(roleList, sysUserList);
ExcelUtil.readBySax(inputStream, 0, currentRowHandler);
......@@ -643,23 +647,29 @@ public class SysUserController {
/**
* 角色code映射
* 角色映射:用来检查是否存在
*/
private Map<String, String> roleMap;
/**
* 用户映射:用来判断角色是否存在
*/
private Set<String> userSet;
/**
* 用户列表
*/
public List<SysUser> sysUserList;
/**
* 用户角色id
*/
public List<SysUserRole> sysUserRoleList;
public CurrentRowHandler(List<SysRole> roles) {
public CurrentRowHandler(List<SysRole> roles, List<SysUser> sysUsers) {
this.disposeMark = true;
this.msg = new StringBuffer();
// 将角色映射表
......@@ -667,6 +677,13 @@ public class SysUserController {
for (SysRole role : roles) {
roleMap.put(role.getRoleName(), role.getId());
}
// 将用户放入映射表中
this.userSet = new HashSet<>();
for (SysUser sysUser : sysUsers) {
userSet.add(sysUser.getUsername());
}
this.sysUserList = new ArrayList<>();
this.sysUserRoleList = new ArrayList<>();
}
......@@ -681,14 +698,17 @@ public class SysUserController {
String realName = Convert.toStr(rowList.get(0));
if (ObjectUtil.isEmpty(realName)) {
this.disposeMark = false;
msg.append("第【" + rowIndex + 1 + "】行名称不能为空");
msg.append("第【" + (rowIndex + 1) + "】行名称不能为空");
}
// 工号 = 用户账号
String username = Convert.toStr(rowList.get(1));
if (ObjectUtil.isEmpty(username)) {
this.disposeMark = false;
msg.append("第【" + rowIndex + 1 + "】行工号不能为空");
msg.append("第【" + (rowIndex + 1) + "】行工号不能为空");
} else if (userSet.contains(username)) {
this.disposeMark = false;
msg.append("第【" + (rowIndex + 1) + "】行已存在");
}
// 身份 中文
......@@ -696,13 +716,13 @@ public class SysUserController {
Integer userIdentity = 1;
if (ObjectUtil.isEmpty(userIdentityStr)) {
this.disposeMark = false;
msg.append("第【" + rowIndex + 1 + "】行身份不能为空");
msg.append("第【" + (rowIndex + 1) + "】行身份不能为空");
} else if ("正式".equals(userIdentityStr)) {
userIdentity = 1;
} else if ("委外".equals(userIdentityStr)) {
userIdentity = 2;
} else {
msg.append("第【" + rowIndex + 1 + "】行身份识别失败");
msg.append("第【" + (rowIndex + 1) + "】行身份识别失败");
}
// 角色名称
......@@ -710,11 +730,11 @@ public class SysUserController {
String roleId = "";
if (ObjectUtil.isEmpty(roleName)) {
this.disposeMark = false;
msg.append("第【" + rowIndex + 1 + "】行角色不能为空");
msg.append("第【" + (rowIndex + 1) + "】行角色不能为空");
} else if (roleMap.containsKey(roleName)) {
roleId = roleMap.get(roleName);
} else {
msg.append("第【" + rowIndex + 1 + "】行角色识别失败");
msg.append("第【" + (rowIndex + 1) + "】行角色识别失败");
}
// 添加换行符号
......@@ -725,10 +745,10 @@ public class SysUserController {
SysUser currentUser = new SysUser();
currentUser.setId(IdWorker.getIdStr());
currentUser.setUsername(username);
currentUser.setRealname(roleName);
currentUser.setRealname(realName);
currentUser.setUserIdentity(userIdentity);// 正式员工身份
currentUser.setWorkNo(username);
currentUser.setDelFlag(0);
currentUser.setDelFlag(CommonConstant.DEL_FLAG_0);
currentUser.setLoginTenantId(0);
currentUser.setStatus(CommonConstant.USER_UNFREEZE);
String salt = oConvertUtils.randomGen(8);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment