管理系统-用户管理-列表查询新增根据用户姓名模糊查询
This commit is contained in:
parent
46ccea4556
commit
d0c8b4ae5f
|
@ -56,6 +56,7 @@ public class SysUserController {
|
|||
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") ,
|
||||
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String") ,
|
||||
@ApiImplicitParam(name = "username", value = "用户名", paramType = "query", dataType="String"),
|
||||
@ApiImplicitParam(name = "real_name", value = "姓名", paramType = "query", dataType="String"),
|
||||
@ApiImplicitParam(name = "gender", value = "性别", paramType = "query", dataType="String"),
|
||||
@ApiImplicitParam(name = "deptId", value = "部门ID", paramType = "query", dataType="String"),
|
||||
@ApiImplicitParam(name = "postId", value = "岗位ID", paramType = "query", dataType="String")
|
||||
|
|
|
@ -63,7 +63,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
|||
@Override
|
||||
public PageData<SysUserDTO> page(Map<String, Object> params) {
|
||||
//转换成like
|
||||
paramsToLike(params, "username");
|
||||
paramsToLike(params, "username", "real_name");
|
||||
|
||||
//分页
|
||||
IPage<SysUserEntity> page = getPage(params, Constant.CREATE_DATE, false);
|
||||
|
@ -78,6 +78,8 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
|||
List<SysUserEntity> list = baseDao.getList(params);
|
||||
|
||||
return getPageData(list, page.getTotal(), SysUserDTO.class);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -210,152 +212,149 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
|||
|
||||
try {
|
||||
ExecutorService executorService = Executors.newSingleThreadExecutor();
|
||||
executorService.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (int n = 0; n < size; n++) {
|
||||
executorService.execute(() -> {
|
||||
for (int n = 0; n < size; n++) {
|
||||
|
||||
Map map1 = deptList.get(n);
|
||||
Set<String> set = map1.keySet();
|
||||
String mName = "";
|
||||
for (String s : set) {
|
||||
mName = s;
|
||||
}
|
||||
String key = mName;//区名,“即墨区”
|
||||
Map map1 = deptList.get(n);
|
||||
Set<String> set = map1.keySet();
|
||||
String mName = "";
|
||||
for (String s : set) {
|
||||
mName = s;
|
||||
}
|
||||
String key = mName;//区名,“即墨区”
|
||||
|
||||
String[] ouStr = (String[]) map1.get(key);
|
||||
String[] ouStr = (String[]) map1.get(key);
|
||||
|
||||
for (String ou : ouStr) {
|
||||
String OU = ou + "," + "OU=" + mName;
|
||||
LdapContext ldapContext = jhlDAPTool.LDAP_connect(OU);
|
||||
List<Map<String, Object>> lists = jhlDAPTool.readLdap(ldapContext, "(&(OU=*)(ou=*)(!(sAMAccountType=*))(instanceType=4))");
|
||||
//Iterator<Map<String,Object>> iterator = lists.iterator();
|
||||
//给pid pids赋值
|
||||
if (lists.size() > 0) {
|
||||
lists.forEach(dept -> {//1.遍历每一个map
|
||||
String namespace = dept.get("namespace").toString();
|
||||
//OU=地税局分局,OU=驻区单位,OU=新市北区,DC=qd,DC=gov,DC=cn
|
||||
String[] namespaces = namespace.split(",");
|
||||
//判断namespaces的长度,
|
||||
for (int i = 1; i < namespaces.length - 3; i++) {//遍历每一个map的namespace
|
||||
String dName = namespaces[i].split("=")[1];//具体的上级部门名称
|
||||
int c = i;
|
||||
for (int j = 0; j < lists.size(); j++) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
if (dName.equals(lists.get(j).get("name").toString())) {
|
||||
String id = lists.get(j).get("id").toString();
|
||||
String pidsOld = dept.get("pids").toString() == "" ? "" : (dept.get("pids").toString() + ",");
|
||||
if (c == 1) {
|
||||
dept.put("pid", id);
|
||||
dept.put("pids", pidsOld + id);
|
||||
} else {
|
||||
dept.put("pids", pidsOld + id);
|
||||
}
|
||||
break;
|
||||
for (String ou : ouStr) {
|
||||
String OU = ou + "," + "OU=" + mName;
|
||||
LdapContext ldapContext = jhlDAPTool.LDAP_connect(OU);
|
||||
List<Map<String, Object>> lists = jhlDAPTool.readLdap(ldapContext, "(&(OU=*)(ou=*)(!(sAMAccountType=*))(instanceType=4))");
|
||||
//Iterator<Map<String,Object>> iterator = lists.iterator();
|
||||
//给pid pids赋值
|
||||
if (lists.size() > 0) {
|
||||
lists.forEach(dept -> {//1.遍历每一个map
|
||||
String namespace = dept.get("namespace").toString();
|
||||
//OU=地税局分局,OU=驻区单位,OU=新市北区,DC=qd,DC=gov,DC=cn
|
||||
String[] namespaces = namespace.split(",");
|
||||
//判断namespaces的长度,
|
||||
for (int i = 1; i < namespaces.length - 3; i++) {//遍历每一个map的namespace
|
||||
String dName = namespaces[i].split("=")[1];//具体的上级部门名称
|
||||
int c = i;
|
||||
for (int j = 0; j < lists.size(); j++) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
if (dName.equals(lists.get(j).get("name").toString())) {
|
||||
String id = lists.get(j).get("id").toString();
|
||||
String pidsOld = dept.get("pids").toString() == "" ? "" : (dept.get("pids").toString() + ",");
|
||||
if (c == 1) {
|
||||
dept.put("pid", id);
|
||||
dept.put("pids", pidsOld + id);
|
||||
} else {
|
||||
dept.put("pids", pidsOld + id);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
//给district和type赋值
|
||||
String districtName, type;
|
||||
Long distict;
|
||||
switch (key) {
|
||||
case "新市北区":
|
||||
districtName = "市北区";
|
||||
distict = getDistict(districtName);
|
||||
lists.forEach(l -> {
|
||||
l.put("district", distict);
|
||||
String name = l.get("name").toString();
|
||||
if (name.contains("企业") || name.contains("集团") || name.contains("公司")) {
|
||||
l.put("type", 4);
|
||||
} else {
|
||||
l.put("type", 3);
|
||||
}
|
||||
});
|
||||
break;
|
||||
case "青岛市级":
|
||||
districtName = "青岛市";
|
||||
distict = getDistict(districtName);
|
||||
lists.forEach(l -> {
|
||||
l.put("district", distict);
|
||||
l.put("type", 2);
|
||||
});
|
||||
break;
|
||||
case "莱西市用户":
|
||||
districtName = "莱西市";
|
||||
distict = getDistict(districtName);
|
||||
lists.forEach(l -> {
|
||||
l.put("district", distict);
|
||||
String name = l.get("name").toString();
|
||||
if (name.contains("企业") || name.contains("集团") || name.contains("公司")) {
|
||||
l.put("type", 4);
|
||||
} else {
|
||||
l.put("type", 3);
|
||||
}
|
||||
});
|
||||
break;
|
||||
case "黄岛区":
|
||||
districtName = "西海岸新区";
|
||||
distict = getDistict(districtName);
|
||||
lists.forEach(l -> {
|
||||
l.put("district", distict);
|
||||
String name = l.get("name").toString();
|
||||
if (name.contains("企业") || name.contains("集团") || name.contains("公司")) {
|
||||
l.put("type", 4);
|
||||
} else {
|
||||
l.put("type", 3);
|
||||
}
|
||||
});
|
||||
break;
|
||||
case "市直企业":
|
||||
distict = getDistict("青岛市");
|
||||
lists.forEach(l -> {
|
||||
l.put("district", distict);
|
||||
l.put("type", 4);
|
||||
});
|
||||
break;
|
||||
case "市直机关":
|
||||
distict = getDistict("青岛市");
|
||||
lists.forEach(l -> {
|
||||
l.put("district", distict);
|
||||
l.put("type", 2);
|
||||
});
|
||||
break;
|
||||
case "驻青单位":
|
||||
distict = getDistict("山东省");
|
||||
lists.forEach(l -> {
|
||||
l.put("district", distict);
|
||||
l.put("type", 1);
|
||||
});
|
||||
break;
|
||||
default:
|
||||
distict = getDistict(mName);
|
||||
lists.forEach(l -> {
|
||||
l.put("district", distict);
|
||||
String name = l.get("name").toString();
|
||||
if (name.contains("企业") || name.contains("集团") || name.contains("公司")) {
|
||||
l.put("type", 4);
|
||||
} else {
|
||||
l.put("type", 3);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
lists.forEach(list -> {//如果有该ID和name,目前暂不处理,,否则插入
|
||||
SysDeptEntity dept = sysDeptDao.getById(Long.valueOf(list.get("id").toString()));
|
||||
|
||||
SysDeptEntity deptNew = new SysDeptEntity();
|
||||
deptNew.setName(list.get("name").toString());
|
||||
deptNew.setId(Long.valueOf(list.get("id").toString()));
|
||||
deptNew.setPid(Long.valueOf(list.get("pid").toString()));
|
||||
deptNew.setPids(list.get("pids").toString());
|
||||
deptNew.setDistrict(Long.valueOf(list.get("district").toString()));
|
||||
deptNew.setType(Integer.parseInt(list.get("type").toString()));
|
||||
if (dept == null) {
|
||||
sysDeptDao.insert(deptNew);
|
||||
}
|
||||
});
|
||||
});
|
||||
//给district和type赋值
|
||||
String districtName, type;
|
||||
Long distict;
|
||||
switch (key) {
|
||||
case "新市北区":
|
||||
districtName = "市北区";
|
||||
distict = getDistict(districtName);
|
||||
lists.forEach(l -> {
|
||||
l.put("district", distict);
|
||||
String name = l.get("name").toString();
|
||||
if (name.contains("企业") || name.contains("集团") || name.contains("公司")) {
|
||||
l.put("type", 4);
|
||||
} else {
|
||||
l.put("type", 3);
|
||||
}
|
||||
});
|
||||
break;
|
||||
case "青岛市级":
|
||||
districtName = "青岛市";
|
||||
distict = getDistict(districtName);
|
||||
lists.forEach(l -> {
|
||||
l.put("district", distict);
|
||||
l.put("type", 2);
|
||||
});
|
||||
break;
|
||||
case "莱西市用户":
|
||||
districtName = "莱西市";
|
||||
distict = getDistict(districtName);
|
||||
lists.forEach(l -> {
|
||||
l.put("district", distict);
|
||||
String name = l.get("name").toString();
|
||||
if (name.contains("企业") || name.contains("集团") || name.contains("公司")) {
|
||||
l.put("type", 4);
|
||||
} else {
|
||||
l.put("type", 3);
|
||||
}
|
||||
});
|
||||
break;
|
||||
case "黄岛区":
|
||||
districtName = "西海岸新区";
|
||||
distict = getDistict(districtName);
|
||||
lists.forEach(l -> {
|
||||
l.put("district", distict);
|
||||
String name = l.get("name").toString();
|
||||
if (name.contains("企业") || name.contains("集团") || name.contains("公司")) {
|
||||
l.put("type", 4);
|
||||
} else {
|
||||
l.put("type", 3);
|
||||
}
|
||||
});
|
||||
break;
|
||||
case "市直企业":
|
||||
distict = getDistict("青岛市");
|
||||
lists.forEach(l -> {
|
||||
l.put("district", distict);
|
||||
l.put("type", 4);
|
||||
});
|
||||
break;
|
||||
case "市直机关":
|
||||
distict = getDistict("青岛市");
|
||||
lists.forEach(l -> {
|
||||
l.put("district", distict);
|
||||
l.put("type", 2);
|
||||
});
|
||||
break;
|
||||
case "驻青单位":
|
||||
distict = getDistict("山东省");
|
||||
lists.forEach(l -> {
|
||||
l.put("district", distict);
|
||||
l.put("type", 1);
|
||||
});
|
||||
break;
|
||||
default:
|
||||
distict = getDistict(mName);
|
||||
lists.forEach(l -> {
|
||||
l.put("district", distict);
|
||||
String name = l.get("name").toString();
|
||||
if (name.contains("企业") || name.contains("集团") || name.contains("公司")) {
|
||||
l.put("type", 4);
|
||||
} else {
|
||||
l.put("type", 3);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
lists.forEach(list -> {//如果有该ID和name,目前暂不处理,,否则插入
|
||||
SysDeptEntity dept = sysDeptDao.getById(Long.valueOf(list.get("id").toString()));
|
||||
|
||||
SysDeptEntity deptNew = new SysDeptEntity();
|
||||
deptNew.setName(list.get("name").toString());
|
||||
deptNew.setId(Long.valueOf(list.get("id").toString()));
|
||||
deptNew.setPid(Long.valueOf(list.get("pid").toString()));
|
||||
deptNew.setPids(list.get("pids").toString());
|
||||
deptNew.setDistrict(Long.valueOf(list.get("district").toString()));
|
||||
deptNew.setType(Integer.parseInt(list.get("type").toString()));
|
||||
if (dept == null) {
|
||||
sysDeptDao.insert(deptNew);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -374,45 +373,42 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
|||
|
||||
try {
|
||||
ExecutorService executorService = Executors.newSingleThreadExecutor();
|
||||
executorService.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (int i = 1; i <= size; i++) {
|
||||
LdapContext ldapContext = jhlDAPTool.LDAP_connect(deptList.get(i - 1).get(String.valueOf(i)).toString());
|
||||
List<Map> maps = jhlDAPTool.readLdap(ldapContext);
|
||||
if (maps.size() > 0) {
|
||||
maps.forEach(m -> {
|
||||
//根据username判断
|
||||
if (m.get(("username")) != null) {
|
||||
String userName = m.get("username").toString();
|
||||
SysUserEntity user = sysUserDao.getUserByName(userName);
|
||||
if (user == null) {//用户表中没有该用户,插入
|
||||
SysUserEntity newUser = new SysUserEntity();
|
||||
newUser.setUsername(userName);
|
||||
newUser.setSuperAdmin(0);
|
||||
newUser.setGuid(m.get("guid") == null ? "" : m.get("guid").toString());
|
||||
newUser.setId(Long.valueOf(m.get("id") == null ? "0" : m.get("id").toString()));
|
||||
newUser.setRealName(m.get("real_name") == null ? "" : m.get("real_name").toString());
|
||||
newUser.setEmail(m.get("email") == null ? "" : m.get("email").toString());
|
||||
newUser.setMobile(m.get("mobile") == null ? "" : m.get("mobile").toString());
|
||||
newUser.setStatus(1);//账号状态 1正常 0停用
|
||||
//给dept_id赋值
|
||||
String deptNames = m.get("distinguishedName") == null ? "" : m.get("distinguishedName").toString();
|
||||
if (deptNames == null) {
|
||||
newUser.setDeptId(0L);
|
||||
} else {
|
||||
String[] deptArray = deptNames.split(",");
|
||||
String dept, deptFather;
|
||||
dept = deptArray[1];
|
||||
deptFather = deptArray[2];
|
||||
long id = getDeptId(dept.substring(3, dept.length()), deptFather.substring(3, deptFather.length()));
|
||||
newUser.setDeptId(id);
|
||||
sysUserDao.insert(newUser);
|
||||
}
|
||||
executorService.execute(() -> {
|
||||
for (int i = 1; i <= size; i++) {
|
||||
LdapContext ldapContext = jhlDAPTool.LDAP_connect(deptList.get(i - 1).get(String.valueOf(i)).toString());
|
||||
List<Map> maps = jhlDAPTool.readLdap(ldapContext);
|
||||
if (maps.size() > 0) {
|
||||
maps.forEach(m -> {
|
||||
//根据username判断
|
||||
if (m.get(("username")) != null) {
|
||||
String userName = m.get("username").toString();
|
||||
SysUserEntity user = sysUserDao.getUserByName(userName);
|
||||
if (user == null) {//用户表中没有该用户,插入
|
||||
SysUserEntity newUser = new SysUserEntity();
|
||||
newUser.setUsername(userName);
|
||||
newUser.setSuperAdmin(0);
|
||||
newUser.setGuid(m.get("guid") == null ? "" : m.get("guid").toString());
|
||||
newUser.setId(Long.valueOf(m.get("id") == null ? "0" : m.get("id").toString()));
|
||||
newUser.setRealName(m.get("real_name") == null ? "" : m.get("real_name").toString());
|
||||
newUser.setEmail(m.get("email") == null ? "" : m.get("email").toString());
|
||||
newUser.setMobile(m.get("mobile") == null ? "" : m.get("mobile").toString());
|
||||
newUser.setStatus(1);//账号状态 1正常 0停用
|
||||
//给dept_id赋值
|
||||
String deptNames = m.get("distinguishedName") == null ? "" : m.get("distinguishedName").toString();
|
||||
if (deptNames == null) {
|
||||
newUser.setDeptId(0L);
|
||||
} else {
|
||||
String[] deptArray = deptNames.split(",");
|
||||
String dept, deptFather;
|
||||
dept = deptArray[1];
|
||||
deptFather = deptArray[2];
|
||||
long id = getDeptId(dept.substring(3, dept.length()), deptFather.substring(3, deptFather.length()));
|
||||
newUser.setDeptId(id);
|
||||
sysUserDao.insert(newUser);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -426,15 +422,14 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
|||
public SysRegionEntity getRegion(String name) {
|
||||
QueryWrapper<SysRegionEntity> regionWrapper = new QueryWrapper<>();
|
||||
regionWrapper.eq("name", name);
|
||||
SysRegionEntity region = regionDao.selectOne(regionWrapper);
|
||||
return region;
|
||||
return regionDao.selectOne(regionWrapper);
|
||||
}
|
||||
|
||||
public long getDeptId(String deptName, String fatherDeptName) {
|
||||
QueryWrapper<SysDeptEntity> deptWrapper = new QueryWrapper<>();
|
||||
deptWrapper.eq("name", deptName);
|
||||
List<SysDeptEntity> deptList = sysDeptDao.selectList(deptWrapper);
|
||||
if (deptList.size() == 0) {
|
||||
if (deptList.isEmpty()) {
|
||||
return 0;
|
||||
} else if (deptList.size() == 1) {
|
||||
return deptList.get(0).getId();
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
<if test="username != null and username.trim() != ''">
|
||||
and t1.username like #{username}
|
||||
</if>
|
||||
<if test="real_name != null and real_name.trim() != ''">
|
||||
and t1.real_name like #{real_name}
|
||||
</if>
|
||||
<if test="deptId != null and deptId.trim() != ''">
|
||||
and t1.dept_id = #{deptId}
|
||||
</if>
|
||||
|
|
Loading…
Reference in New Issue