Merge branch 'master' into docker_package
This commit is contained in:
commit
c9137ee369
|
@ -21,7 +21,6 @@ import io.renren.modules.resourceMountApply.dto.TResourceMountApplyDTO;
|
|||
import io.renren.modules.resourceMountApply.service.TResourceMountApplyService;
|
||||
import io.renren.modules.security.user.SecurityUser;
|
||||
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.SysUserService;
|
||||
import org.activiti.engine.HistoryService;
|
||||
|
@ -55,6 +54,10 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
|
@ -67,6 +70,9 @@ public class ActTaskService extends BaseServiceImpl {
|
|||
private static final Logger logger = LoggerFactory.getLogger(ActTaskService.class);
|
||||
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_AGREE = "agree"; //同意
|
||||
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));
|
||||
}
|
||||
List<SysUserDTO> sysUserList = sysUserService.list(new HashMap());
|
||||
List<TaskDTO> taskDtoList = new ArrayList<>();
|
||||
for (SysUserDTO user : sysUserList) {
|
||||
String userId = user.getId().toString();
|
||||
TaskQuery taskQuery = taskService.createTaskQuery();
|
||||
if (StringUtils.isNotEmpty(userId)) {
|
||||
taskQuery.taskAssignee(userId);
|
||||
}
|
||||
taskQuery.orderByTaskCreateTime().desc();
|
||||
List<Task> list = taskQuery.active().includeProcessVariables().list();
|
||||
taskDtoList.addAll(tasks2TaskDtos(list));
|
||||
}
|
||||
List<TaskDTO> taskDtoList = new CopyOnWriteArrayList<>();
|
||||
Integer finalCurPage = curPage;
|
||||
Integer finalLimit = limit;
|
||||
List<Long> count = new CopyOnWriteArrayList<>();
|
||||
List<CompletableFuture> completableFutureList =
|
||||
sysUserList.stream().filter(index -> null != index.getId()).map(index -> {
|
||||
CompletableFuture completableFuture = CompletableFuture.runAsync(() -> {
|
||||
TaskQuery taskQuery = taskService.createTaskQuery();
|
||||
List<Task> list = taskQuery.taskAssignee(index.getId().toString())
|
||||
.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);
|
||||
int j = Math.min(curPage * limit, taskDtoList.size());
|
||||
if (taskDtoList.isEmpty()) {
|
||||
|
@ -180,7 +194,7 @@ public class ActTaskService extends BaseServiceImpl {
|
|||
ArrayList<TaskDTO> recordLists = new ArrayList<>();
|
||||
recordLists.addAll(taskDtoList.stream().distinct().skip((curPage - 1) * limit).limit(limit).collect(Collectors.toList()));
|
||||
page.setRecords(recordLists);
|
||||
page.setTotal(taskDtoList.stream().distinct().count());
|
||||
page.setTotal(count.stream().mapToLong(index -> index.longValue()).sum());
|
||||
}
|
||||
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.SysRegionDao;
|
||||
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.entity.SysDeptEntity;
|
||||
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.JhDeptsEnum;
|
||||
import io.renren.modules.sys.enums.SuperAdminEnum;
|
||||
import io.renren.modules.sys.service.SysDeptService;
|
||||
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 io.renren.modules.sys.service.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
@ -56,6 +54,11 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
|||
private SysUserDao sysUserDao;
|
||||
@Autowired
|
||||
private SysRegionDao regionDao;
|
||||
@Autowired
|
||||
private SysRoleService sysRoleService;
|
||||
|
||||
@Value("${big_date.assignee_role_name}")
|
||||
private String roleName; // 具备审批的角色名称
|
||||
|
||||
@Override
|
||||
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()) {
|
||||
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);
|
||||
|
||||
return ConvertUtils.sourceToTarget(entityList, SysUserDTO.class);
|
||||
|
@ -198,11 +204,11 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
|||
}
|
||||
|
||||
@Override
|
||||
public Result getDeptInfoFromJH(){
|
||||
public Result getDeptInfoFromJH() {
|
||||
List<Map> deptList = JhDeptEnum.getAllToList();
|
||||
int size = deptList.size();
|
||||
|
||||
try{
|
||||
try {
|
||||
ExecutorService executorService = Executors.newSingleThreadExecutor();
|
||||
executorService.execute(new Runnable() {
|
||||
@Override
|
||||
|
@ -212,33 +218,33 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
|||
Map map1 = deptList.get(n);
|
||||
Set<String> set = map1.keySet();
|
||||
String mName = "";
|
||||
for(String s:set){
|
||||
for (String s : set) {
|
||||
mName = s;
|
||||
}
|
||||
String key = mName;//区名,“即墨区”
|
||||
String key = mName;//区名,“即墨区”
|
||||
|
||||
String[] ouStr = (String[])map1.get(key);
|
||||
String[] ouStr = (String[]) map1.get(key);
|
||||
|
||||
for(String ou:ouStr){
|
||||
String OU = ou+","+"OU="+mName;
|
||||
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))");
|
||||
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
|
||||
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
|
||||
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() + ",");
|
||||
String pidsOld = dept.get("pids").toString() == "" ? "" : (dept.get("pids").toString() + ",");
|
||||
if (c == 1) {
|
||||
dept.put("pid", id);
|
||||
dept.put("pids", pidsOld + id);
|
||||
|
@ -251,91 +257,91 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
|||
}
|
||||
});
|
||||
//给district和type赋值
|
||||
String districtName,type;
|
||||
String districtName, type;
|
||||
Long distict;
|
||||
switch (key){
|
||||
switch (key) {
|
||||
case "新市北区":
|
||||
districtName = "市北区";
|
||||
distict = getDistict(districtName);
|
||||
lists.forEach(l->{
|
||||
l.put("district",distict);
|
||||
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);
|
||||
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);
|
||||
lists.forEach(l -> {
|
||||
l.put("district", distict);
|
||||
l.put("type", 2);
|
||||
});
|
||||
break;
|
||||
case "莱西市用户":
|
||||
districtName = "莱西市";
|
||||
distict = getDistict(districtName);
|
||||
lists.forEach(l->{
|
||||
l.put("district",distict);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
lists.forEach(l -> {
|
||||
l.put("district", distict);
|
||||
l.put("type", 1);
|
||||
});
|
||||
break;
|
||||
default:
|
||||
distict = getDistict(mName);
|
||||
lists.forEach(l->{
|
||||
l.put("district",distict);
|
||||
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);
|
||||
if (name.contains("企业") || name.contains("集团") || name.contains("公司")) {
|
||||
l.put("type", 4);
|
||||
} else {
|
||||
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 deptNew = new SysDeptEntity();
|
||||
|
@ -345,7 +351,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
|||
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){
|
||||
if (dept == null) {
|
||||
sysDeptDao.insert(deptNew);
|
||||
}
|
||||
});
|
||||
|
@ -355,14 +361,14 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
|||
}
|
||||
});
|
||||
return new Result().ok("保存成功");
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return new Result().error("保存失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result getUserInfoFromJH(){
|
||||
public Result getUserInfoFromJH() {
|
||||
List<Map> deptList = JhDeptsEnum.getAllToList();
|
||||
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());
|
||||
List<Map> maps = jhlDAPTool.readLdap(ldapContext);
|
||||
if (maps.size() > 0) {
|
||||
maps.forEach(m-> {
|
||||
maps.forEach(m -> {
|
||||
//根据username判断
|
||||
if(m.get(("username")) != null){
|
||||
if (m.get(("username")) != null) {
|
||||
String userName = m.get("username").toString();
|
||||
SysUserEntity user = sysUserDao.getUserByName(userName);
|
||||
if(user == null){//用户表中没有该用户,插入
|
||||
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.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){
|
||||
String deptNames = m.get("distinguishedName") == null ? "" : m.get("distinguishedName").toString();
|
||||
if (deptNames == null) {
|
||||
newUser.setDeptId(0L);
|
||||
}else{
|
||||
} else {
|
||||
String[] deptArray = deptNames.split(",");
|
||||
String dept,deptFather;
|
||||
String dept, deptFather;
|
||||
dept = deptArray[1];
|
||||
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);
|
||||
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<>();
|
||||
regionWrapper.eq("name",name);
|
||||
regionWrapper.eq("name", name);
|
||||
SysRegionEntity region = regionDao.selectOne(regionWrapper);
|
||||
return region;
|
||||
}
|
||||
public long getDeptId(String deptName,String fatherDeptName){
|
||||
|
||||
public long getDeptId(String deptName, String fatherDeptName) {
|
||||
QueryWrapper<SysDeptEntity> deptWrapper = new QueryWrapper<>();
|
||||
deptWrapper.eq("name",deptName);
|
||||
deptWrapper.eq("name", deptName);
|
||||
List<SysDeptEntity> deptList = sysDeptDao.selectList(deptWrapper);
|
||||
if(deptList.size() == 0){
|
||||
if (deptList.size() == 0) {
|
||||
return 0;
|
||||
}else if(deptList.size() == 1){
|
||||
} else if (deptList.size() == 1) {
|
||||
return deptList.get(0).getId();
|
||||
}else{//出现多个相同的deptname,根据他们的父级来确定
|
||||
} else {//出现多个相同的deptname,根据他们的父级来确定
|
||||
AtomicLong newId = new AtomicLong();
|
||||
deptList.forEach(dept->{
|
||||
deptList.forEach(dept -> {
|
||||
long fatherId = dept.getPid();//获取其中一个的父级ID
|
||||
SysDeptEntity fatherEntity = sysDeptDao.getById(fatherId);//根据父级ID查询管理部门
|
||||
if(fatherEntity != null && fatherEntity.getName().equals(fatherDeptName)){//如果该管理部门的名称等于传进来的父级名称,那么这条dept就是我们需要的
|
||||
if(fatherEntity.getId() == fatherId){//如果父级ID等于
|
||||
if (fatherEntity != null && fatherEntity.getName().equals(fatherDeptName)) {//如果该管理部门的名称等于传进来的父级名称,那么这条dept就是我们需要的
|
||||
if (fatherEntity.getId() == fatherId) {//如果父级ID等于
|
||||
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<>();
|
||||
regionWrapper.eq("name",deptName);
|
||||
regionWrapper.eq("name", deptName);
|
||||
SysRegionEntity entity = regionDao.selectOne(regionWrapper);
|
||||
if (entity == null) {
|
||||
return 0L;
|
||||
}else{
|
||||
} else {
|
||||
return entity.getId();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
#{id}
|
||||
</foreach>
|
||||
</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 id="getById" resultType="io.renren.modules.sys.entity.SysUserEntity">
|
||||
|
|
Loading…
Reference in New Issue