deptToDoTaskPage接口优化
This commit is contained in:
parent
b843f76d0f
commit
df7e2a3824
|
@ -21,7 +21,6 @@ import io.renren.modules.resourceMountApply.dto.TResourceMountApplyDTO;
|
||||||
import io.renren.modules.resourceMountApply.service.TResourceMountApplyService;
|
import io.renren.modules.resourceMountApply.service.TResourceMountApplyService;
|
||||||
import io.renren.modules.security.user.SecurityUser;
|
import io.renren.modules.security.user.SecurityUser;
|
||||||
import io.renren.modules.sys.dto.SysUserDTO;
|
import io.renren.modules.sys.dto.SysUserDTO;
|
||||||
import io.renren.modules.sys.entity.SysUserEntity;
|
|
||||||
import io.renren.modules.sys.service.SysRoleUserService;
|
import io.renren.modules.sys.service.SysRoleUserService;
|
||||||
import io.renren.modules.sys.service.SysUserService;
|
import io.renren.modules.sys.service.SysUserService;
|
||||||
import org.activiti.engine.HistoryService;
|
import org.activiti.engine.HistoryService;
|
||||||
|
@ -55,6 +54,10 @@ import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,6 +70,9 @@ public class ActTaskService extends BaseServiceImpl {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ActTaskService.class);
|
private static final Logger logger = LoggerFactory.getLogger(ActTaskService.class);
|
||||||
private static final ObjectMapper oMapper = new ObjectMapper();
|
private static final ObjectMapper oMapper = new ObjectMapper();
|
||||||
|
|
||||||
|
private static Integer cpuNUm = Runtime.getRuntime().availableProcessors();
|
||||||
|
private static final ExecutorService executor = Executors.newFixedThreadPool(cpuNUm);
|
||||||
|
|
||||||
public static String Task_HANDLE_STATE = "handleState"; //任务节点处理状态key
|
public static String Task_HANDLE_STATE = "handleState"; //任务节点处理状态key
|
||||||
public static String Task_HANDLE_STATE_AGREE = "agree"; //同意
|
public static String Task_HANDLE_STATE_AGREE = "agree"; //同意
|
||||||
public static String Task_HANDLE_STATE_REJECTED = "rejected"; //驳回
|
public static String Task_HANDLE_STATE_REJECTED = "rejected"; //驳回
|
||||||
|
@ -160,17 +166,25 @@ public class ActTaskService extends BaseServiceImpl {
|
||||||
limit = Integer.parseInt((String) params.get(Constant.LIMIT));
|
limit = Integer.parseInt((String) params.get(Constant.LIMIT));
|
||||||
}
|
}
|
||||||
List<SysUserDTO> sysUserList = sysUserService.list(new HashMap());
|
List<SysUserDTO> sysUserList = sysUserService.list(new HashMap());
|
||||||
List<TaskDTO> taskDtoList = new ArrayList<>();
|
List<TaskDTO> taskDtoList = new CopyOnWriteArrayList<>();
|
||||||
for (SysUserDTO user : sysUserList) {
|
Integer finalCurPage = curPage;
|
||||||
String userId = user.getId().toString();
|
Integer finalLimit = limit;
|
||||||
TaskQuery taskQuery = taskService.createTaskQuery();
|
List<Long> count = new CopyOnWriteArrayList<>();
|
||||||
if (StringUtils.isNotEmpty(userId)) {
|
List<CompletableFuture> completableFutureList =
|
||||||
taskQuery.taskAssignee(userId);
|
sysUserList.stream().filter(index -> null != index.getId()).map(index -> {
|
||||||
}
|
CompletableFuture completableFuture = CompletableFuture.runAsync(() -> {
|
||||||
taskQuery.orderByTaskCreateTime().desc();
|
TaskQuery taskQuery = taskService.createTaskQuery();
|
||||||
List<Task> list = taskQuery.active().includeProcessVariables().list();
|
List<Task> list = taskQuery.taskAssignee(index.getId().toString())
|
||||||
taskDtoList.addAll(tasks2TaskDtos(list));
|
.orderByTaskCreateTime().desc()
|
||||||
}
|
.includeProcessVariables()
|
||||||
|
.listPage((finalCurPage - 1) * finalLimit, finalCurPage * finalLimit);
|
||||||
|
count.add(taskQuery.taskAssignee(index.getId().toString())
|
||||||
|
.orderByTaskCreateTime().desc().count());
|
||||||
|
taskDtoList.addAll(tasks2TaskDtos(list));
|
||||||
|
});
|
||||||
|
return completableFuture;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
CompletableFuture.allOf(completableFutureList.toArray(new CompletableFuture[completableFutureList.size()])).join();
|
||||||
Page<TaskDTO> page = new Page(curPage, limit);
|
Page<TaskDTO> page = new Page(curPage, limit);
|
||||||
int j = Math.min(curPage * limit, taskDtoList.size());
|
int j = Math.min(curPage * limit, taskDtoList.size());
|
||||||
if (taskDtoList.isEmpty()) {
|
if (taskDtoList.isEmpty()) {
|
||||||
|
@ -180,7 +194,7 @@ public class ActTaskService extends BaseServiceImpl {
|
||||||
ArrayList<TaskDTO> recordLists = new ArrayList<>();
|
ArrayList<TaskDTO> recordLists = new ArrayList<>();
|
||||||
recordLists.addAll(taskDtoList.stream().distinct().skip((curPage - 1) * limit).limit(limit).collect(Collectors.toList()));
|
recordLists.addAll(taskDtoList.stream().distinct().skip((curPage - 1) * limit).limit(limit).collect(Collectors.toList()));
|
||||||
page.setRecords(recordLists);
|
page.setRecords(recordLists);
|
||||||
page.setTotal(taskDtoList.stream().distinct().count());
|
page.setTotal(count.stream().mapToLong(index -> index.longValue()).sum());
|
||||||
}
|
}
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import io.renren.modules.security.user.UserDetail;
|
||||||
import io.renren.modules.sys.dao.SysDeptDao;
|
import io.renren.modules.sys.dao.SysDeptDao;
|
||||||
import io.renren.modules.sys.dao.SysRegionDao;
|
import io.renren.modules.sys.dao.SysRegionDao;
|
||||||
import io.renren.modules.sys.dao.SysUserDao;
|
import io.renren.modules.sys.dao.SysUserDao;
|
||||||
|
import io.renren.modules.sys.dto.SysRoleDTO;
|
||||||
import io.renren.modules.sys.dto.SysUserDTO;
|
import io.renren.modules.sys.dto.SysUserDTO;
|
||||||
import io.renren.modules.sys.entity.SysDeptEntity;
|
import io.renren.modules.sys.entity.SysDeptEntity;
|
||||||
import io.renren.modules.sys.entity.SysRegionEntity;
|
import io.renren.modules.sys.entity.SysRegionEntity;
|
||||||
|
@ -21,12 +22,9 @@ import io.renren.modules.sys.entity.SysUserEntity;
|
||||||
import io.renren.modules.sys.enums.JhDeptEnum;
|
import io.renren.modules.sys.enums.JhDeptEnum;
|
||||||
import io.renren.modules.sys.enums.JhDeptsEnum;
|
import io.renren.modules.sys.enums.JhDeptsEnum;
|
||||||
import io.renren.modules.sys.enums.SuperAdminEnum;
|
import io.renren.modules.sys.enums.SuperAdminEnum;
|
||||||
import io.renren.modules.sys.service.SysDeptService;
|
import io.renren.modules.sys.service.*;
|
||||||
import io.renren.modules.sys.service.SysRoleUserService;
|
|
||||||
import io.renren.modules.sys.service.SysUserPostService;
|
|
||||||
import io.renren.modules.sys.service.SysUserService;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@ -56,6 +54,11 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
||||||
private SysUserDao sysUserDao;
|
private SysUserDao sysUserDao;
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysRegionDao regionDao;
|
private SysRegionDao regionDao;
|
||||||
|
@Autowired
|
||||||
|
private SysRoleService sysRoleService;
|
||||||
|
|
||||||
|
@Value("${big_date.assignee_role_name}")
|
||||||
|
private String roleName; // 具备审批的角色名称
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageData<SysUserDTO> page(Map<String, Object> params) {
|
public PageData<SysUserDTO> page(Map<String, Object> params) {
|
||||||
|
@ -84,7 +87,10 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
||||||
if (user.getSuperAdmin() == SuperAdminEnum.NO.value()) {
|
if (user.getSuperAdmin() == SuperAdminEnum.NO.value()) {
|
||||||
params.put("deptIdList", sysDeptService.getSubDeptIdList(user.getDeptId()));
|
params.put("deptIdList", sysDeptService.getSubDeptIdList(user.getDeptId()));
|
||||||
}
|
}
|
||||||
|
SysRoleDTO roleDTO = sysRoleService.getByName(roleName);
|
||||||
|
if (roleDTO != null) {
|
||||||
|
params.put("role_id", roleDTO.getId());
|
||||||
|
}
|
||||||
List<SysUserEntity> entityList = baseDao.getList(params);
|
List<SysUserEntity> entityList = baseDao.getList(params);
|
||||||
|
|
||||||
return ConvertUtils.sourceToTarget(entityList, SysUserDTO.class);
|
return ConvertUtils.sourceToTarget(entityList, SysUserDTO.class);
|
||||||
|
@ -198,11 +204,11 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result getDeptInfoFromJH(){
|
public Result getDeptInfoFromJH() {
|
||||||
List<Map> deptList = JhDeptEnum.getAllToList();
|
List<Map> deptList = JhDeptEnum.getAllToList();
|
||||||
int size = deptList.size();
|
int size = deptList.size();
|
||||||
|
|
||||||
try{
|
try {
|
||||||
ExecutorService executorService = Executors.newSingleThreadExecutor();
|
ExecutorService executorService = Executors.newSingleThreadExecutor();
|
||||||
executorService.execute(new Runnable() {
|
executorService.execute(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -212,33 +218,33 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
||||||
Map map1 = deptList.get(n);
|
Map map1 = deptList.get(n);
|
||||||
Set<String> set = map1.keySet();
|
Set<String> set = map1.keySet();
|
||||||
String mName = "";
|
String mName = "";
|
||||||
for(String s:set){
|
for (String s : set) {
|
||||||
mName = s;
|
mName = s;
|
||||||
}
|
}
|
||||||
String key = mName;//区名,“即墨区”
|
String key = mName;//区名,“即墨区”
|
||||||
|
|
||||||
String[] ouStr = (String[])map1.get(key);
|
String[] ouStr = (String[]) map1.get(key);
|
||||||
|
|
||||||
for(String ou:ouStr){
|
for (String ou : ouStr) {
|
||||||
String OU = ou+","+"OU="+mName;
|
String OU = ou + "," + "OU=" + mName;
|
||||||
LdapContext ldapContext = jhlDAPTool.LDAP_connect(OU);
|
LdapContext ldapContext = jhlDAPTool.LDAP_connect(OU);
|
||||||
List<Map<String,Object>> lists = jhlDAPTool.readLdap(ldapContext,"(&(OU=*)(ou=*)(!(sAMAccountType=*))(instanceType=4))");
|
List<Map<String, Object>> lists = jhlDAPTool.readLdap(ldapContext, "(&(OU=*)(ou=*)(!(sAMAccountType=*))(instanceType=4))");
|
||||||
//Iterator<Map<String,Object>> iterator = lists.iterator();
|
//Iterator<Map<String,Object>> iterator = lists.iterator();
|
||||||
//给pid pids赋值
|
//给pid pids赋值
|
||||||
if (lists.size() > 0) {
|
if (lists.size() > 0) {
|
||||||
lists.forEach(dept->{//1.遍历每一个map
|
lists.forEach(dept -> {//1.遍历每一个map
|
||||||
String namespace = dept.get("namespace").toString();
|
String namespace = dept.get("namespace").toString();
|
||||||
//OU=地税局分局,OU=驻区单位,OU=新市北区,DC=qd,DC=gov,DC=cn
|
//OU=地税局分局,OU=驻区单位,OU=新市北区,DC=qd,DC=gov,DC=cn
|
||||||
String[] namespaces = namespace.split(",");
|
String[] namespaces = namespace.split(",");
|
||||||
//判断namespaces的长度,
|
//判断namespaces的长度,
|
||||||
for(int i=1;i<namespaces.length-3;i++) {//遍历每一个map的namespace
|
for (int i = 1; i < namespaces.length - 3; i++) {//遍历每一个map的namespace
|
||||||
String dName = namespaces[i].split("=")[1];//具体的上级部门名称
|
String dName = namespaces[i].split("=")[1];//具体的上级部门名称
|
||||||
int c = i;
|
int c = i;
|
||||||
for (int j = 0; j < lists.size(); j++) {
|
for (int j = 0; j < lists.size(); j++) {
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
if (dName.equals(lists.get(j).get("name").toString())) {
|
if (dName.equals(lists.get(j).get("name").toString())) {
|
||||||
String id = lists.get(j).get("id").toString();
|
String id = lists.get(j).get("id").toString();
|
||||||
String pidsOld = dept.get("pids").toString() == ""? "" : (dept.get("pids").toString() + ",");
|
String pidsOld = dept.get("pids").toString() == "" ? "" : (dept.get("pids").toString() + ",");
|
||||||
if (c == 1) {
|
if (c == 1) {
|
||||||
dept.put("pid", id);
|
dept.put("pid", id);
|
||||||
dept.put("pids", pidsOld + id);
|
dept.put("pids", pidsOld + id);
|
||||||
|
@ -251,91 +257,91 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//给district和type赋值
|
//给district和type赋值
|
||||||
String districtName,type;
|
String districtName, type;
|
||||||
Long distict;
|
Long distict;
|
||||||
switch (key){
|
switch (key) {
|
||||||
case "新市北区":
|
case "新市北区":
|
||||||
districtName = "市北区";
|
districtName = "市北区";
|
||||||
distict = getDistict(districtName);
|
distict = getDistict(districtName);
|
||||||
lists.forEach(l->{
|
lists.forEach(l -> {
|
||||||
l.put("district",distict);
|
l.put("district", distict);
|
||||||
String name = l.get("name").toString();
|
String name = l.get("name").toString();
|
||||||
if(name.contains("企业") || name.contains("集团") || name.contains("公司")){
|
if (name.contains("企业") || name.contains("集团") || name.contains("公司")) {
|
||||||
l.put("type",4);
|
l.put("type", 4);
|
||||||
}else{
|
} else {
|
||||||
l.put("type",3);
|
l.put("type", 3);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "青岛市级":
|
case "青岛市级":
|
||||||
districtName = "青岛市";
|
districtName = "青岛市";
|
||||||
distict = getDistict(districtName);
|
distict = getDistict(districtName);
|
||||||
lists.forEach(l->{
|
lists.forEach(l -> {
|
||||||
l.put("district",distict);
|
l.put("district", distict);
|
||||||
l.put("type",2);
|
l.put("type", 2);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "莱西市用户":
|
case "莱西市用户":
|
||||||
districtName = "莱西市";
|
districtName = "莱西市";
|
||||||
distict = getDistict(districtName);
|
distict = getDistict(districtName);
|
||||||
lists.forEach(l->{
|
lists.forEach(l -> {
|
||||||
l.put("district",distict);
|
l.put("district", distict);
|
||||||
String name = l.get("name").toString();
|
String name = l.get("name").toString();
|
||||||
if(name.contains("企业") || name.contains("集团") || name.contains("公司")){
|
if (name.contains("企业") || name.contains("集团") || name.contains("公司")) {
|
||||||
l.put("type",4);
|
l.put("type", 4);
|
||||||
}else{
|
} else {
|
||||||
l.put("type",3);
|
l.put("type", 3);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "黄岛区":
|
case "黄岛区":
|
||||||
districtName = "西海岸新区";
|
districtName = "西海岸新区";
|
||||||
distict = getDistict(districtName);
|
distict = getDistict(districtName);
|
||||||
lists.forEach(l->{
|
lists.forEach(l -> {
|
||||||
l.put("district",distict);
|
l.put("district", distict);
|
||||||
String name = l.get("name").toString();
|
String name = l.get("name").toString();
|
||||||
if(name.contains("企业") || name.contains("集团") || name.contains("公司")){
|
if (name.contains("企业") || name.contains("集团") || name.contains("公司")) {
|
||||||
l.put("type",4);
|
l.put("type", 4);
|
||||||
}else{
|
} else {
|
||||||
l.put("type",3);
|
l.put("type", 3);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "市直企业":
|
case "市直企业":
|
||||||
distict = getDistict("青岛市");
|
distict = getDistict("青岛市");
|
||||||
lists.forEach(l->{
|
lists.forEach(l -> {
|
||||||
l.put("district",distict);
|
l.put("district", distict);
|
||||||
l.put("type",4);
|
l.put("type", 4);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "市直机关":
|
case "市直机关":
|
||||||
distict = getDistict("青岛市");
|
distict = getDistict("青岛市");
|
||||||
lists.forEach(l->{
|
lists.forEach(l -> {
|
||||||
l.put("district",distict);
|
l.put("district", distict);
|
||||||
l.put("type",2);
|
l.put("type", 2);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "驻青单位":
|
case "驻青单位":
|
||||||
distict = getDistict("山东省");
|
distict = getDistict("山东省");
|
||||||
lists.forEach(l->{
|
lists.forEach(l -> {
|
||||||
l.put("district",distict);
|
l.put("district", distict);
|
||||||
l.put("type",1);
|
l.put("type", 1);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
distict = getDistict(mName);
|
distict = getDistict(mName);
|
||||||
lists.forEach(l->{
|
lists.forEach(l -> {
|
||||||
l.put("district",distict);
|
l.put("district", distict);
|
||||||
String name = l.get("name").toString();
|
String name = l.get("name").toString();
|
||||||
if(name.contains("企业") || name.contains("集团") || name.contains("公司")){
|
if (name.contains("企业") || name.contains("集团") || name.contains("公司")) {
|
||||||
l.put("type",4);
|
l.put("type", 4);
|
||||||
}else{
|
} else {
|
||||||
l.put("type",3);
|
l.put("type", 3);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
lists.forEach(list->{//如果有该ID和name,目前暂不处理,,否则插入
|
lists.forEach(list -> {//如果有该ID和name,目前暂不处理,,否则插入
|
||||||
SysDeptEntity dept = sysDeptDao.getById(Long.valueOf(list.get("id").toString()));
|
SysDeptEntity dept = sysDeptDao.getById(Long.valueOf(list.get("id").toString()));
|
||||||
|
|
||||||
SysDeptEntity deptNew = new SysDeptEntity();
|
SysDeptEntity deptNew = new SysDeptEntity();
|
||||||
|
@ -345,7 +351,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
||||||
deptNew.setPids(list.get("pids").toString());
|
deptNew.setPids(list.get("pids").toString());
|
||||||
deptNew.setDistrict(Long.valueOf(list.get("district").toString()));
|
deptNew.setDistrict(Long.valueOf(list.get("district").toString()));
|
||||||
deptNew.setType(Integer.parseInt(list.get("type").toString()));
|
deptNew.setType(Integer.parseInt(list.get("type").toString()));
|
||||||
if(dept == null){
|
if (dept == null) {
|
||||||
sysDeptDao.insert(deptNew);
|
sysDeptDao.insert(deptNew);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -355,14 +361,14 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return new Result().ok("保存成功");
|
return new Result().ok("保存成功");
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return new Result().error("保存失败");
|
return new Result().error("保存失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result getUserInfoFromJH(){
|
public Result getUserInfoFromJH() {
|
||||||
List<Map> deptList = JhDeptsEnum.getAllToList();
|
List<Map> deptList = JhDeptsEnum.getAllToList();
|
||||||
int size = deptList.size();
|
int size = deptList.size();
|
||||||
|
|
||||||
|
@ -375,31 +381,31 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
||||||
LdapContext ldapContext = jhlDAPTool.LDAP_connect(deptList.get(i - 1).get(String.valueOf(i)).toString());
|
LdapContext ldapContext = jhlDAPTool.LDAP_connect(deptList.get(i - 1).get(String.valueOf(i)).toString());
|
||||||
List<Map> maps = jhlDAPTool.readLdap(ldapContext);
|
List<Map> maps = jhlDAPTool.readLdap(ldapContext);
|
||||||
if (maps.size() > 0) {
|
if (maps.size() > 0) {
|
||||||
maps.forEach(m-> {
|
maps.forEach(m -> {
|
||||||
//根据username判断
|
//根据username判断
|
||||||
if(m.get(("username")) != null){
|
if (m.get(("username")) != null) {
|
||||||
String userName = m.get("username").toString();
|
String userName = m.get("username").toString();
|
||||||
SysUserEntity user = sysUserDao.getUserByName(userName);
|
SysUserEntity user = sysUserDao.getUserByName(userName);
|
||||||
if(user == null){//用户表中没有该用户,插入
|
if (user == null) {//用户表中没有该用户,插入
|
||||||
SysUserEntity newUser = new SysUserEntity();
|
SysUserEntity newUser = new SysUserEntity();
|
||||||
newUser.setUsername(userName);
|
newUser.setUsername(userName);
|
||||||
newUser.setSuperAdmin(0);
|
newUser.setSuperAdmin(0);
|
||||||
newUser.setGuid(m.get("guid") == null ? "":m.get("guid").toString());
|
newUser.setGuid(m.get("guid") == null ? "" : m.get("guid").toString());
|
||||||
newUser.setId(Long.valueOf(m.get("id") == null ? "0":m.get("id").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.setRealName(m.get("real_name") == null ? "" : m.get("real_name").toString());
|
||||||
newUser.setEmail(m.get("email") == null ?"":m.get("email").toString());
|
newUser.setEmail(m.get("email") == null ? "" : m.get("email").toString());
|
||||||
newUser.setMobile(m.get("mobile") == null ?"":m.get("mobile").toString());
|
newUser.setMobile(m.get("mobile") == null ? "" : m.get("mobile").toString());
|
||||||
newUser.setStatus(1);//账号状态 1正常 0停用
|
newUser.setStatus(1);//账号状态 1正常 0停用
|
||||||
//给dept_id赋值
|
//给dept_id赋值
|
||||||
String deptNames = m.get("distinguishedName") == null ? "":m.get("distinguishedName").toString();
|
String deptNames = m.get("distinguishedName") == null ? "" : m.get("distinguishedName").toString();
|
||||||
if(deptNames == null){
|
if (deptNames == null) {
|
||||||
newUser.setDeptId(0L);
|
newUser.setDeptId(0L);
|
||||||
}else{
|
} else {
|
||||||
String[] deptArray = deptNames.split(",");
|
String[] deptArray = deptNames.split(",");
|
||||||
String dept,deptFather;
|
String dept, deptFather;
|
||||||
dept = deptArray[1];
|
dept = deptArray[1];
|
||||||
deptFather = deptArray[2];
|
deptFather = deptArray[2];
|
||||||
long id = getDeptId(dept.substring(3,dept.length()),deptFather.substring(3,deptFather.length()));
|
long id = getDeptId(dept.substring(3, dept.length()), deptFather.substring(3, deptFather.length()));
|
||||||
newUser.setDeptId(id);
|
newUser.setDeptId(id);
|
||||||
sysUserDao.insert(newUser);
|
sysUserDao.insert(newUser);
|
||||||
}
|
}
|
||||||
|
@ -417,27 +423,28 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SysRegionEntity getRegion(String name){
|
public SysRegionEntity getRegion(String name) {
|
||||||
QueryWrapper<SysRegionEntity> regionWrapper = new QueryWrapper<>();
|
QueryWrapper<SysRegionEntity> regionWrapper = new QueryWrapper<>();
|
||||||
regionWrapper.eq("name",name);
|
regionWrapper.eq("name", name);
|
||||||
SysRegionEntity region = regionDao.selectOne(regionWrapper);
|
SysRegionEntity region = regionDao.selectOne(regionWrapper);
|
||||||
return region;
|
return region;
|
||||||
}
|
}
|
||||||
public long getDeptId(String deptName,String fatherDeptName){
|
|
||||||
|
public long getDeptId(String deptName, String fatherDeptName) {
|
||||||
QueryWrapper<SysDeptEntity> deptWrapper = new QueryWrapper<>();
|
QueryWrapper<SysDeptEntity> deptWrapper = new QueryWrapper<>();
|
||||||
deptWrapper.eq("name",deptName);
|
deptWrapper.eq("name", deptName);
|
||||||
List<SysDeptEntity> deptList = sysDeptDao.selectList(deptWrapper);
|
List<SysDeptEntity> deptList = sysDeptDao.selectList(deptWrapper);
|
||||||
if(deptList.size() == 0){
|
if (deptList.size() == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}else if(deptList.size() == 1){
|
} else if (deptList.size() == 1) {
|
||||||
return deptList.get(0).getId();
|
return deptList.get(0).getId();
|
||||||
}else{//出现多个相同的deptname,根据他们的父级来确定
|
} else {//出现多个相同的deptname,根据他们的父级来确定
|
||||||
AtomicLong newId = new AtomicLong();
|
AtomicLong newId = new AtomicLong();
|
||||||
deptList.forEach(dept->{
|
deptList.forEach(dept -> {
|
||||||
long fatherId = dept.getPid();//获取其中一个的父级ID
|
long fatherId = dept.getPid();//获取其中一个的父级ID
|
||||||
SysDeptEntity fatherEntity = sysDeptDao.getById(fatherId);//根据父级ID查询管理部门
|
SysDeptEntity fatherEntity = sysDeptDao.getById(fatherId);//根据父级ID查询管理部门
|
||||||
if(fatherEntity != null && fatherEntity.getName().equals(fatherDeptName)){//如果该管理部门的名称等于传进来的父级名称,那么这条dept就是我们需要的
|
if (fatherEntity != null && fatherEntity.getName().equals(fatherDeptName)) {//如果该管理部门的名称等于传进来的父级名称,那么这条dept就是我们需要的
|
||||||
if(fatherEntity.getId() == fatherId){//如果父级ID等于
|
if (fatherEntity.getId() == fatherId) {//如果父级ID等于
|
||||||
newId.set(dept.getId());
|
newId.set(dept.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -446,13 +453,13 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getDistict(String deptName){
|
public Long getDistict(String deptName) {
|
||||||
QueryWrapper<SysRegionEntity> regionWrapper = new QueryWrapper<>();
|
QueryWrapper<SysRegionEntity> regionWrapper = new QueryWrapper<>();
|
||||||
regionWrapper.eq("name",deptName);
|
regionWrapper.eq("name", deptName);
|
||||||
SysRegionEntity entity = regionDao.selectOne(regionWrapper);
|
SysRegionEntity entity = regionDao.selectOne(regionWrapper);
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
return 0L;
|
return 0L;
|
||||||
}else{
|
} else {
|
||||||
return entity.getId();
|
return entity.getId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,9 @@
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
|
<if test="role_id != null">
|
||||||
|
AND EXISTS(SELECT 1 FROM sys_role_user WHERE sys_role_user.user_id = t1.id AND sys_role_user.role_id = #{role_id})
|
||||||
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getById" resultType="io.renren.modules.sys.entity.SysUserEntity">
|
<select id="getById" resultType="io.renren.modules.sys.entity.SysUserEntity">
|
||||||
|
|
Loading…
Reference in New Issue