|
|
|
@ -2,6 +2,7 @@ package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;
|
|
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.core.api.iservice.busi.ICoreTreeService;
|
|
|
|
|
import cn.estsh.i3plus.core.apiservice.dao.ISysMenuDao;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.util.CommonConstWords;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.BaseBean;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.ModelEnumUtil;
|
|
|
|
@ -17,13 +18,16 @@ import cn.estsh.i3plus.pojo.platform.repository.SysOrganizeRepository;
|
|
|
|
|
import cn.estsh.i3plus.pojo.platform.repository.SysPositionRepository;
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionEnum;
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.ImppRedis;
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.ValidatorBean;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
@ -55,6 +59,12 @@ public class CoreTreeService implements ICoreTreeService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private ISysMenuDao sysMenuDao;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 核心的缓存
|
|
|
|
|
*/
|
|
|
|
|
@Resource(name="redisCore")
|
|
|
|
|
protected ImppRedis redisCore;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@ApiOperation(value = "获取岗位树",notes = "根据父节点获取岗位树集合")
|
|
|
|
|
public List<SysPosition> findSysPositionTreeByParentId(long parentId) {
|
|
|
|
@ -216,7 +226,7 @@ public class CoreTreeService implements ICoreTreeService {
|
|
|
|
|
StringBuffer orgHQL = new StringBuffer();
|
|
|
|
|
HqlPack.getNumEqualPack(parentId,"parentId",orgHQL);
|
|
|
|
|
HqlPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"organizeSort"}, orgHQL);
|
|
|
|
|
List<SysOrganize> result = organizeRDao.findByHqlWhere(orgHQL.toString());
|
|
|
|
|
List<SysOrganize> result = findSysOrganizeCacheByHqlWhere(orgHQL.toString());
|
|
|
|
|
|
|
|
|
|
// 循环设置子集
|
|
|
|
|
if(result != null && result.size() > 0){
|
|
|
|
@ -263,7 +273,7 @@ public class CoreTreeService implements ICoreTreeService {
|
|
|
|
|
StringBuffer orgHQL = new StringBuffer();
|
|
|
|
|
HqlPack.getNumEqualPack(parent.getId(),"parentId",orgHQL);
|
|
|
|
|
HqlPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"organizeSort"}, orgHQL);
|
|
|
|
|
List<SysOrganize> childList = organizeRDao.findByHqlWhere(orgHQL.toString());
|
|
|
|
|
List<SysOrganize> childList = findSysOrganizeCacheByHqlWhere(orgHQL.toString());
|
|
|
|
|
|
|
|
|
|
if (childList.size() > 0) { //说明有子集
|
|
|
|
|
for (SysOrganize child : childList) {
|
|
|
|
@ -406,7 +416,7 @@ public class CoreTreeService implements ICoreTreeService {
|
|
|
|
|
StringBuffer hql = new StringBuffer();
|
|
|
|
|
HqlPack.getNumEqualPack(parentId,"parentId",hql);
|
|
|
|
|
HqlPack.getOrderByPack(new Object[]{2}, new String[]{"organizeSort"}, hql);
|
|
|
|
|
List<SysOrganize> list = organizeRDao.findByHqlWhere(hql.toString());
|
|
|
|
|
List<SysOrganize> list = findSysOrganizeCacheByHqlWhere(hql.toString());
|
|
|
|
|
|
|
|
|
|
// 循环设置子集
|
|
|
|
|
if(list != null && list.size() > 0){
|
|
|
|
@ -455,7 +465,7 @@ public class CoreTreeService implements ICoreTreeService {
|
|
|
|
|
StringBuffer hql = new StringBuffer();
|
|
|
|
|
HqlPack.getNumEqualPack(organize.getId(),"parentId",hql);
|
|
|
|
|
HqlPack.getOrderByPack(new Object[]{2}, new String[]{"organizeSort"}, hql);
|
|
|
|
|
List<SysOrganize> organizeList = organizeRDao.findByHqlWhere(hql.toString());
|
|
|
|
|
List<SysOrganize> organizeList = findSysOrganizeCacheByHqlWhere(hql.toString());
|
|
|
|
|
|
|
|
|
|
if(organizeList != null && organizeList.size() > 0){
|
|
|
|
|
for (SysOrganize org : organizeList) {
|
|
|
|
@ -472,7 +482,7 @@ public class CoreTreeService implements ICoreTreeService {
|
|
|
|
|
StringBuffer depHQL = new StringBuffer();
|
|
|
|
|
HqlPack.getNumEqualPack(organize.getId(),"organizeId",depHQL);
|
|
|
|
|
HqlPack.getOrderByPack(new Object[]{2}, new String[]{"departmentSort"}, depHQL);
|
|
|
|
|
List<SysDepartment> departmentList = departmentRDao.findByHqlWhere(depHQL.toString());
|
|
|
|
|
List<SysDepartment> departmentList = findSysDepartmentCacheByHqlWhere(depHQL.toString());
|
|
|
|
|
|
|
|
|
|
if(departmentList != null && departmentList.size() > 0){
|
|
|
|
|
for (SysDepartment department : departmentList) {
|
|
|
|
@ -494,7 +504,8 @@ public class CoreTreeService implements ICoreTreeService {
|
|
|
|
|
StringBuffer depHQL = new StringBuffer();
|
|
|
|
|
HqlPack.getNumEqualPack(department.getId(),"parentId",depHQL);
|
|
|
|
|
HqlPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"departmentSort"}, depHQL);
|
|
|
|
|
List<SysDepartment> departmentList = departmentRDao.findByHqlWhere(depHQL.toString());
|
|
|
|
|
|
|
|
|
|
List<SysDepartment> departmentList = findSysDepartmentCacheByHqlWhere(depHQL.toString());
|
|
|
|
|
|
|
|
|
|
if(departmentList != null && departmentList.size() > 0){
|
|
|
|
|
for (SysDepartment dep : departmentList) {
|
|
|
|
@ -584,4 +595,36 @@ public class CoreTreeService implements ICoreTreeService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<SysDepartment> findSysDepartmentCacheByHqlWhere(String hql){
|
|
|
|
|
if(!StringUtils.isBlank(hql)){
|
|
|
|
|
String redisKey = CommonConstWords.REDIS_PREFIX_CACHE_DEPARTMENT+ "_findCacheByHqlWhere" + "_" + hql.hashCode();
|
|
|
|
|
List list = redisCore.getList(redisKey, 0, -1);
|
|
|
|
|
if(list == null){
|
|
|
|
|
list = departmentRDao.findByHqlWhere(hql);
|
|
|
|
|
if(list != null){
|
|
|
|
|
redisCore.putList(redisKey,list,CommonConstWords.REDIS_TIME_DAY_ONE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
}else {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<SysOrganize> findSysOrganizeCacheByHqlWhere(String hql){
|
|
|
|
|
if(!StringUtils.isBlank(hql)){
|
|
|
|
|
String redisKey = CommonConstWords.REDIS_PREFIX_CACHE_ORGANIZE+ "_findCacheByHqlWhere" + "_" + hql.hashCode();
|
|
|
|
|
List list = redisCore.getList(redisKey, 0, -1);
|
|
|
|
|
if(list == null){
|
|
|
|
|
list = organizeRDao.findByHqlWhere(hql);
|
|
|
|
|
if(list != null){
|
|
|
|
|
redisCore.putList(redisKey,list,CommonConstWords.REDIS_TIME_DAY_ONE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
}else {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|