|
|
|
@ -9,20 +9,22 @@ import com.engine.organization.component.OrganizationWeaTable;
|
|
|
|
|
import com.engine.organization.entity.browser.bo.CusBowserTreeBO;
|
|
|
|
|
import com.engine.organization.entity.browser.enums.TreeNodeTypeEnum;
|
|
|
|
|
import com.engine.organization.entity.browser.po.CusBrowserTree;
|
|
|
|
|
import com.engine.organization.entity.company.po.CompPO;
|
|
|
|
|
import com.engine.organization.entity.department.po.DepartmentPO;
|
|
|
|
|
import com.engine.organization.entity.job.vo.JobBrowserVO;
|
|
|
|
|
import com.engine.organization.entity.searchtree.SearchTree;
|
|
|
|
|
import com.engine.organization.entity.searchtree.SearchTreeParams;
|
|
|
|
|
import com.engine.organization.service.impl.JobServiceImpl;
|
|
|
|
|
import com.engine.organization.mapper.comp.CompMapper;
|
|
|
|
|
import com.engine.organization.mapper.department.DepartmentMapper;
|
|
|
|
|
import com.engine.organization.util.OrganizationFormItemUtil;
|
|
|
|
|
import com.engine.organization.util.db.DBType;
|
|
|
|
|
import com.engine.organization.util.db.MapperProxyFactory;
|
|
|
|
|
import com.engine.organization.util.tree.SearchTreeUtil;
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
import weaver.conn.RecordSet;
|
|
|
|
|
import weaver.general.Util;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author:dxfeng
|
|
|
|
@ -38,35 +40,19 @@ public class JobBrowserService extends BrowserService {
|
|
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
|
|
String datatype = Util.null2String(params.get("datatype"));
|
|
|
|
|
if ("tree".equals(datatype)) {
|
|
|
|
|
List<TreeNode> nodeData = new ArrayList<>();
|
|
|
|
|
String id = Util.null2String(params.get("id"));
|
|
|
|
|
SearchTreeParams searchTreeParams = new SearchTreeParams();
|
|
|
|
|
if (StringUtils.isBlank(id)) {
|
|
|
|
|
Map<String, Object> searchTree = new JobServiceImpl().getSearchTree(searchTreeParams);
|
|
|
|
|
Map<String, Object> datas = (Map<String, Object>) searchTree.get("datas");
|
|
|
|
|
// 集团
|
|
|
|
|
SearchTree rootCompany = (SearchTree) datas.get("rootCompany");
|
|
|
|
|
nodeData.add(rootCompany);
|
|
|
|
|
} else if ("0".equals(id)) {
|
|
|
|
|
Map<String, Object> searchTree = new JobServiceImpl().getSearchTree(searchTreeParams);
|
|
|
|
|
Map<String, Object> datas = (Map<String, Object>) searchTree.get("datas");
|
|
|
|
|
SearchTree rootCompany = (SearchTree) datas.get("rootCompany");
|
|
|
|
|
nodeData.addAll(rootCompany.getSubs());
|
|
|
|
|
} else {
|
|
|
|
|
String[] idArray = id.split("_");
|
|
|
|
|
if (idArray.length == 2) {
|
|
|
|
|
if (TreeNodeTypeEnum.TYPE_COMP.getName().equals(idArray[0])) {
|
|
|
|
|
searchTreeParams.setType(TreeNodeTypeEnum.TYPE_COMP.getValue());
|
|
|
|
|
} else if (TreeNodeTypeEnum.TYPE_DEPT.getName().equals(idArray[0])) {
|
|
|
|
|
searchTreeParams.setType(TreeNodeTypeEnum.TYPE_DEPT.getValue());
|
|
|
|
|
}
|
|
|
|
|
searchTreeParams.setId(idArray[1]);
|
|
|
|
|
Map<String, Object> searchTree = new JobServiceImpl().getSearchTree(searchTreeParams);
|
|
|
|
|
List<TreeNode> datas = (List<TreeNode>) searchTree.get("datas");
|
|
|
|
|
TreeNode treeNode = datas.stream().filter(item -> idArray[1].equals(item.getId())).findFirst().orElse(new TreeNode());
|
|
|
|
|
nodeData.addAll(treeNode.getSubs());
|
|
|
|
|
searchTreeParams.setId(id);
|
|
|
|
|
String[] idArray = id.split("_");
|
|
|
|
|
if (idArray.length == 2) {
|
|
|
|
|
if (TreeNodeTypeEnum.TYPE_COMP.getName().equals(idArray[0])) {
|
|
|
|
|
searchTreeParams.setType(TreeNodeTypeEnum.TYPE_COMP.getValue());
|
|
|
|
|
} else if (TreeNodeTypeEnum.TYPE_DEPT.getName().equals(idArray[0])) {
|
|
|
|
|
searchTreeParams.setType(TreeNodeTypeEnum.TYPE_DEPT.getValue());
|
|
|
|
|
}
|
|
|
|
|
searchTreeParams.setId(idArray[1]);
|
|
|
|
|
}
|
|
|
|
|
List<TreeNode> nodeData = getCurrentTreeNode(searchTreeParams);
|
|
|
|
|
List<CusBrowserTree> cusBrowserTrees = CusBowserTreeBO.convertSearchTreeToBorwserTree(nodeData);
|
|
|
|
|
resultMap.put("datas", cusBrowserTrees);
|
|
|
|
|
} else {
|
|
|
|
@ -140,4 +126,79 @@ public class JobBrowserService extends BrowserService {
|
|
|
|
|
}
|
|
|
|
|
return sqlWhere;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取当前点击节点下的层级数据
|
|
|
|
|
*
|
|
|
|
|
* @param params
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private List<TreeNode> getCurrentTreeNode(SearchTreeParams params) {
|
|
|
|
|
List<TreeNode> treeNodes = new ArrayList<>();
|
|
|
|
|
if (StringUtils.isBlank(params.getId())) {
|
|
|
|
|
// 集团总部
|
|
|
|
|
SearchTree topGroup = SearchTreeUtil.getTopGroup();
|
|
|
|
|
topGroup.setIsParent(true);
|
|
|
|
|
treeNodes.add(topGroup);
|
|
|
|
|
} else {
|
|
|
|
|
// 分部存在下级的ID
|
|
|
|
|
List<String> compHasSubs = MapperProxyFactory.getProxy(CompMapper.class).hasSubs();
|
|
|
|
|
// 部门存在下级的ID
|
|
|
|
|
List<String> hasSubDepartment = MapperProxyFactory.getProxy(DepartmentMapper.class).hasSubs();
|
|
|
|
|
|
|
|
|
|
if ("0".equals(params.getId())) {
|
|
|
|
|
List<CompPO> compList = MapperProxyFactory.getProxy(CompMapper.class).listParent();
|
|
|
|
|
// 获取顶层分部
|
|
|
|
|
compList.stream().sorted(Comparator.comparing(CompPO::getShowOrder)).forEach(item -> buildCompNodes(treeNodes, compHasSubs, item));
|
|
|
|
|
} else if ("1".equals(params.getType())) {
|
|
|
|
|
// 当前节点下的元素
|
|
|
|
|
CompPO compBuild = CompPO.builder().parentCompany(Long.parseLong(params.getId())).forbiddenTag(0).deleteType(0).build();
|
|
|
|
|
List<CompPO> compList = MapperProxyFactory.getProxy(CompMapper.class).listByFilter(compBuild, "show_order");
|
|
|
|
|
DepartmentPO departmentBuild = DepartmentPO.builder().parentComp(Long.parseLong(params.getId())).forbiddenTag(0).deleteType(0).build();
|
|
|
|
|
List<DepartmentPO> departmentList = MapperProxyFactory.getProxy(DepartmentMapper.class).listByFilter(departmentBuild, "show_order");
|
|
|
|
|
compList.forEach(item -> buildCompNodes(treeNodes, compHasSubs, item));
|
|
|
|
|
|
|
|
|
|
departmentList.stream().filter(item -> null == item.getParentDept() || 0 == item.getParentDept()).forEach(item -> buildDeptNodes(treeNodes, hasSubDepartment, item));
|
|
|
|
|
} else if ("2".equals(params.getType())) {
|
|
|
|
|
DepartmentPO departmentBuild = DepartmentPO.builder().parentDept(Long.parseLong(params.getId())).forbiddenTag(0).deleteType(0).build();
|
|
|
|
|
List<DepartmentPO> departmentList = MapperProxyFactory.getProxy(DepartmentMapper.class).listByFilter(departmentBuild, "show_order");
|
|
|
|
|
departmentList.forEach(item -> buildDeptNodes(treeNodes, hasSubDepartment, item));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return treeNodes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 构建分部节点
|
|
|
|
|
*
|
|
|
|
|
* @param treeNodes
|
|
|
|
|
* @param compHasSubs
|
|
|
|
|
* @param company
|
|
|
|
|
*/
|
|
|
|
|
private void buildCompNodes(List<TreeNode> treeNodes, List<String> compHasSubs, CompPO company) {
|
|
|
|
|
SearchTree searchTree = new SearchTree();
|
|
|
|
|
searchTree.setId(company.getId().toString());
|
|
|
|
|
searchTree.setType(TreeNodeTypeEnum.TYPE_COMP.getValue());
|
|
|
|
|
searchTree.setName(company.getCompName());
|
|
|
|
|
searchTree.setIsParent(compHasSubs.contains(company.getId().toString()));
|
|
|
|
|
treeNodes.add(searchTree);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 构建部门节点
|
|
|
|
|
*
|
|
|
|
|
* @param treeNodes
|
|
|
|
|
* @param hasSubDepartment
|
|
|
|
|
* @param department
|
|
|
|
|
*/
|
|
|
|
|
private void buildDeptNodes(List<TreeNode> treeNodes, List<String> hasSubDepartment, DepartmentPO department) {
|
|
|
|
|
SearchTree searchTree = new SearchTree();
|
|
|
|
|
searchTree.setId(department.getId().toString());
|
|
|
|
|
searchTree.setName(department.getDeptName());
|
|
|
|
|
searchTree.setType(TreeNodeTypeEnum.TYPE_DEPT.getValue());
|
|
|
|
|
searchTree.setIsParent(hasSubDepartment.contains(department.getId().toString()));
|
|
|
|
|
treeNodes.add(searchTree);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|