commit
8bfedbd2a7
|
|
@ -204,26 +204,12 @@ public class CompServiceImpl extends Service implements CompService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getHasRight() {
|
public Map<String, Object> getHasRight() {
|
||||||
Map<String, Object> btnDatas = new HashMap<>();
|
return MenuBtn.getDatasNoBtnColum();
|
||||||
ArrayList<MenuBtn> topMenuList = new ArrayList<>();
|
|
||||||
ArrayList<MenuBtn> rightMenuList = new ArrayList<>();
|
|
||||||
// 新增
|
|
||||||
topMenuList.add(MenuBtn.topMenu_addNew());
|
|
||||||
// 批量删除
|
|
||||||
topMenuList.add(MenuBtn.topMenu_batchDelete());
|
|
||||||
btnDatas.put("topMenu", topMenuList);
|
|
||||||
// 新增
|
|
||||||
rightMenuList.add(MenuBtn.rightMenu_addNew());
|
|
||||||
// 日志
|
|
||||||
rightMenuList.add(MenuBtn.rightMenu_btnLog());
|
|
||||||
btnDatas.put("rightMenu", rightMenuList);
|
|
||||||
return btnDatas;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getCompBaseForm(Map<String, Object> params) {
|
public Map<String, Object> getCompBaseForm(Map<String, Object> params) {
|
||||||
OrganizationAssert.notNull(params.get("viewAttr"), "请标识操作类型");
|
OrganizationAssert.notNull(params.get("viewAttr"), "请标识操作类型");
|
||||||
|
|
||||||
// 2编辑 1查看
|
// 2编辑 1查看
|
||||||
int viewAttr = Integer.parseInt((String) params.get("viewAttr"));
|
int viewAttr = Integer.parseInt((String) params.get("viewAttr"));
|
||||||
long id = Long.parseLong((String) params.get("id"));
|
long id = Long.parseLong((String) params.get("id"));
|
||||||
|
|
@ -271,6 +257,23 @@ public class CompServiceImpl extends Service implements CompService {
|
||||||
compNoItem.setHelpfulTip("编号为空,则按照指定规则自动生成编号");
|
compNoItem.setHelpfulTip("编号为空,则按照指定规则自动生成编号");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getSameFormItem(conditionItems, compNoItem, null);
|
||||||
|
|
||||||
|
|
||||||
|
addGroups.add(new SearchConditionGroup("基本信息", true, conditionItems));
|
||||||
|
apiDatas.put("condition", addGroups);
|
||||||
|
|
||||||
|
return apiDatas;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增、编辑表单,相同属性
|
||||||
|
*
|
||||||
|
* @param conditionItems
|
||||||
|
* @param compNoItem
|
||||||
|
*/
|
||||||
|
private void getSameFormItem(List<SearchConditionItem> conditionItems, SearchConditionItem compNoItem, Long id) {
|
||||||
// 名称
|
// 名称
|
||||||
SearchConditionItem compNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "名称", "compName");
|
SearchConditionItem compNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "名称", "compName");
|
||||||
compNameItem.setRules("required|string");
|
compNameItem.setRules("required|string");
|
||||||
|
|
@ -299,12 +302,36 @@ public class CompServiceImpl extends Service implements CompService {
|
||||||
conditionItems.add(compPrincipalItem);
|
conditionItems.add(compPrincipalItem);
|
||||||
conditionItems.add(descriptionItem);
|
conditionItems.add(descriptionItem);
|
||||||
|
|
||||||
|
if (null == id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 赋值
|
||||||
|
CompPO compPO = getCompMapper().listById(id);
|
||||||
|
OrganizationAssert.notNull(compPO, "数据不存在或数据已删除");
|
||||||
|
compNoItem.setValue(compPO.getCompNo());
|
||||||
|
compNameItem.setValue(compPO.getCompName());
|
||||||
|
compNameShortItem.setValue(compPO.getCompNameShort());
|
||||||
|
|
||||||
addGroups.add(new SearchConditionGroup("基本信息", true, conditionItems));
|
// compBrowserItem
|
||||||
apiDatas.put("condition", addGroups);
|
if (null != compPO.getParentCompany()) {
|
||||||
|
BrowserBean compBrowserBean = compBrowserItem.getBrowserConditionParam();
|
||||||
return apiDatas;
|
compBrowserBean.setReplaceDatas(creatReplaceDatas(compPO.getParentCompany(), getCompMapper().listById(compPO.getParentCompany()).getCompName()));
|
||||||
|
compBrowserItem.setBrowserConditionParam(compBrowserBean);
|
||||||
|
}
|
||||||
|
orgCodeItem.setValue(compPO.getOrgCode());
|
||||||
|
// industryItem
|
||||||
|
BrowserBean industryBean = industryItem.getBrowserConditionParam();
|
||||||
|
industryBean.setReplaceDatas(creatReplaceDatas(compPO.getIndustry(), new SectorInfoComInfo().getSectorInfoname(compPO.getIndustry() + "")));
|
||||||
|
industryItem.setBrowserConditionParam(industryBean);
|
||||||
|
try {
|
||||||
|
// compPrincipalItem
|
||||||
|
BrowserBean PrincipalBean = compPrincipalItem.getBrowserConditionParam();
|
||||||
|
PrincipalBean.setReplaceDatas(creatReplaceDatas(compPO.getCompPrincipal(), new ResourceComInfo().getLastname(compPO.getCompPrincipal() + "")));
|
||||||
|
compPrincipalItem.setBrowserConditionParam(PrincipalBean);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
descriptionItem.setValue(compPO.getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -354,67 +381,7 @@ public class CompServiceImpl extends Service implements CompService {
|
||||||
List<SearchConditionItem> conditionItems = new ArrayList<>();
|
List<SearchConditionItem> conditionItems = new ArrayList<>();
|
||||||
// 编号
|
// 编号
|
||||||
SearchConditionItem compNoItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 1, 50, "编号", "compNo");
|
SearchConditionItem compNoItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 1, 50, "编号", "compNo");
|
||||||
// 名称
|
getSameFormItem(conditionItems, compNoItem, id);
|
||||||
SearchConditionItem compNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "名称", "compName");
|
|
||||||
compNameItem.setRules("required|string");
|
|
||||||
// 简称
|
|
||||||
SearchConditionItem compNameShortItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "简称", "compNameShort");
|
|
||||||
compNameShortItem.setRules("required|string");
|
|
||||||
// TODO 自定义按钮
|
|
||||||
// 上级公司
|
|
||||||
SearchConditionItem compBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "上级公司", "161", "parentCompany", "compBrowser");
|
|
||||||
// 组织机构代码
|
|
||||||
SearchConditionItem orgCodeItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "组织机构代码", "orgCode");
|
|
||||||
orgCodeItem.setRules("required|string");
|
|
||||||
// 行业
|
|
||||||
SearchConditionItem industryItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "行业", "63", "industry", "");
|
|
||||||
// 负责人
|
|
||||||
SearchConditionItem compPrincipalItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "负责人", "1", "compPrincipal", "");
|
|
||||||
compPrincipalItem.setRules("required|string");
|
|
||||||
// 说明
|
|
||||||
SearchConditionItem descriptionItem = OrganizationFormItemUtil.textareaItem(user, 2, 16, true, 2, 60, "说明", "description");
|
|
||||||
|
|
||||||
|
|
||||||
conditionItems.add(compNoItem);
|
|
||||||
conditionItems.add(compNameItem);
|
|
||||||
conditionItems.add(compNameShortItem);
|
|
||||||
conditionItems.add(compBrowserItem);
|
|
||||||
conditionItems.add(orgCodeItem);
|
|
||||||
conditionItems.add(industryItem);
|
|
||||||
conditionItems.add(compPrincipalItem);
|
|
||||||
conditionItems.add(descriptionItem);
|
|
||||||
|
|
||||||
|
|
||||||
// 编辑、查看状态赋值,设置只读状态
|
|
||||||
|
|
||||||
// 赋值
|
|
||||||
CompPO compPO = getCompMapper().listById(id);
|
|
||||||
OrganizationAssert.notNull(compPO, "数据不存在或数据已删除");
|
|
||||||
compNoItem.setValue(compPO.getCompNo());
|
|
||||||
compNameItem.setValue(compPO.getCompName());
|
|
||||||
compNameShortItem.setValue(compPO.getCompNameShort());
|
|
||||||
|
|
||||||
// compBrowserItem
|
|
||||||
if (null != compPO.getParentCompany()) {
|
|
||||||
BrowserBean compBrowserBean = compBrowserItem.getBrowserConditionParam();
|
|
||||||
compBrowserBean.setReplaceDatas(creatReplaceDatas(compPO.getParentCompany(), getCompMapper().listById(compPO.getParentCompany()).getCompName()));
|
|
||||||
compBrowserItem.setBrowserConditionParam(compBrowserBean);
|
|
||||||
}
|
|
||||||
orgCodeItem.setValue(compPO.getOrgCode());
|
|
||||||
// industryItem
|
|
||||||
BrowserBean industryBean = industryItem.getBrowserConditionParam();
|
|
||||||
industryBean.setReplaceDatas(creatReplaceDatas(compPO.getIndustry(), new SectorInfoComInfo().getSectorInfoname(compPO.getIndustry() + "")));
|
|
||||||
industryItem.setBrowserConditionParam(industryBean);
|
|
||||||
try {
|
|
||||||
// compPrincipalItem
|
|
||||||
BrowserBean PrincipalBean = compPrincipalItem.getBrowserConditionParam();
|
|
||||||
PrincipalBean.setReplaceDatas(creatReplaceDatas(compPO.getCompPrincipal(), new ResourceComInfo().getLastname(compPO.getCompPrincipal() + "")));
|
|
||||||
compPrincipalItem.setBrowserConditionParam(PrincipalBean);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
descriptionItem.setValue(compPO.getDescription());
|
|
||||||
|
|
||||||
// 查看,全部置位只读
|
// 查看,全部置位只读
|
||||||
if (1 == viewAttr) {
|
if (1 == viewAttr) {
|
||||||
for (SearchConditionItem item : conditionItems) {
|
for (SearchConditionItem item : conditionItems) {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import com.api.browser.bean.BrowserBean;
|
||||||
import com.api.browser.bean.SearchConditionGroup;
|
import com.api.browser.bean.SearchConditionGroup;
|
||||||
import com.api.browser.bean.SearchConditionItem;
|
import com.api.browser.bean.SearchConditionItem;
|
||||||
import com.api.browser.bean.SearchConditionOption;
|
import com.api.browser.bean.SearchConditionOption;
|
||||||
import com.api.hrm.bean.TreeNode;
|
|
||||||
import com.cloudstore.eccom.pc.table.WeaTableColumn;
|
import com.cloudstore.eccom.pc.table.WeaTableColumn;
|
||||||
import com.cloudstore.eccom.result.WeaResultMsg;
|
import com.cloudstore.eccom.result.WeaResultMsg;
|
||||||
import com.engine.common.util.ServiceUtil;
|
import com.engine.common.util.ServiceUtil;
|
||||||
|
|
@ -40,8 +39,8 @@ import com.engine.organization.util.db.MapperProxyFactory;
|
||||||
import com.engine.organization.util.page.Column;
|
import com.engine.organization.util.page.Column;
|
||||||
import com.engine.organization.util.page.PageInfo;
|
import com.engine.organization.util.page.PageInfo;
|
||||||
import com.engine.organization.util.page.PageUtil;
|
import com.engine.organization.util.page.PageUtil;
|
||||||
|
import com.engine.organization.util.tree.SearchTreeUtil;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import weaver.conn.RecordSet;
|
|
||||||
import weaver.general.StringUtil;
|
import weaver.general.StringUtil;
|
||||||
import weaver.general.Util;
|
import weaver.general.Util;
|
||||||
import weaver.hrm.User;
|
import weaver.hrm.User;
|
||||||
|
|
@ -73,14 +72,6 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
||||||
*/
|
*/
|
||||||
private static final String JCL_ORG_DEPTEXT_DT1 = "JCL_ORG_DEPTEXT_DT1";
|
private static final String JCL_ORG_DEPTEXT_DT1 = "JCL_ORG_DEPTEXT_DT1";
|
||||||
|
|
||||||
/**
|
|
||||||
* 左侧树 类型表示
|
|
||||||
* <p>
|
|
||||||
* 0:集团
|
|
||||||
* 1:分部
|
|
||||||
* 2:部门
|
|
||||||
*/
|
|
||||||
private static final String TYPE_GROUP = "0";
|
|
||||||
|
|
||||||
private DepartmentMapper getDepartmentMapper() {
|
private DepartmentMapper getDepartmentMapper() {
|
||||||
return MapperProxyFactory.getProxy(DepartmentMapper.class);
|
return MapperProxyFactory.getProxy(DepartmentMapper.class);
|
||||||
|
|
@ -130,30 +121,11 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getSearchTree(SearchTreeParams params) {
|
public Map<String, Object> getSearchTree(SearchTreeParams params) {
|
||||||
Map<String, Object> dataMap = new HashMap<>();
|
|
||||||
SearchTree topGroup = getTopGroup();
|
|
||||||
// 集团
|
|
||||||
List<SearchTree> companyList = new ArrayList<>();
|
|
||||||
companyList.add(topGroup);
|
|
||||||
String keyword = params.getKeyword();
|
String keyword = params.getKeyword();
|
||||||
String type = Util.null2String(params.getType());
|
|
||||||
String id = params.getId();
|
String id = params.getId();
|
||||||
|
String type = Util.null2String(params.getType());
|
||||||
List<TreeNode> treeDatas = getFilterCompany(id, keyword);
|
List<SearchTree> treeList = getFilterCompany(id, keyword);
|
||||||
// 未点击,初始化树结构
|
return SearchTreeUtil.getSearchTree(type, treeList);
|
||||||
if (StringUtil.isEmpty(type)) {
|
|
||||||
dataMap.put("companys", companyList);
|
|
||||||
SearchTree rootCompany = getTopGroup();
|
|
||||||
rootCompany.setSubs(treeDatas);
|
|
||||||
rootCompany.setIsParent(CollectionUtils.isNotEmpty(rootCompany.getSubs()));
|
|
||||||
Map<String, Object> rootCompanyMap = new HashMap<>();
|
|
||||||
rootCompanyMap.put("rootCompany", rootCompany);
|
|
||||||
dataMap.put("datas", rootCompanyMap);
|
|
||||||
} else {
|
|
||||||
// 根据ID查询
|
|
||||||
dataMap.put("datas", treeDatas);
|
|
||||||
}
|
|
||||||
return dataMap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -202,9 +174,8 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
||||||
public int saveBaseForm(DeptSearchParam params) {
|
public int saveBaseForm(DeptSearchParam params) {
|
||||||
try {
|
try {
|
||||||
// 处理自动编号
|
// 处理自动编号
|
||||||
String departmentNo = CodeRuleManager.getCodeRuleManager().generateRuleCode(RuleCodeType.
|
params.setDeptNo(CodeRuleManager.getCodeRuleManager().generateRuleCode(RuleCodeType.
|
||||||
DEPARTMENT, params.getDeptNo());
|
DEPARTMENT, params.getDeptNo()));
|
||||||
params.setDeptNo(departmentNo);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
@ -253,7 +224,6 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
||||||
SearchConditionItem deptNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "名称", "departmentName");
|
SearchConditionItem deptNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "名称", "departmentName");
|
||||||
// 简称
|
// 简称
|
||||||
SearchConditionItem deptNameShortItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "简称", "deptNameShort");
|
SearchConditionItem deptNameShortItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "简称", "deptNameShort");
|
||||||
// TODO
|
|
||||||
// 所属分部
|
// 所属分部
|
||||||
SearchConditionItem parentCompBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "所属分部", "161", "parentComp", "compBrowser");
|
SearchConditionItem parentCompBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "所属分部", "161", "parentComp", "compBrowser");
|
||||||
// 上级部门
|
// 上级部门
|
||||||
|
|
@ -422,15 +392,25 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
||||||
List<Long> idList = Arrays.stream(copyParam.getIds().split(",")).map(Long::parseLong).collect(Collectors.toList());
|
List<Long> idList = Arrays.stream(copyParam.getIds().split(",")).map(Long::parseLong).collect(Collectors.toList());
|
||||||
for (Long id : idList) {
|
for (Long id : idList) {
|
||||||
DepartmentPO deptById = getDepartmentMapper().getDeptById(id);
|
DepartmentPO deptById = getDepartmentMapper().getDeptById(id);
|
||||||
// TODO 自动编号
|
try {
|
||||||
deptById.setDeptNo("复制_" + deptById.getDeptNo());
|
// 处理自动编号
|
||||||
|
deptById.setDeptNo(CodeRuleManager.getCodeRuleManager().generateRuleCode(RuleCodeType.
|
||||||
|
DEPARTMENT, ""));
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
deptById.setParentComp(Long.parseLong(copyParam.getCompany()));
|
deptById.setParentComp(Long.parseLong(copyParam.getCompany()));
|
||||||
insertCount += getDepartmentMapper().insertIgnoreNull(deptById);
|
insertCount += getDepartmentMapper().insertIgnoreNull(deptById);
|
||||||
if ("1".equals(copyParam.getCopyJob())) {
|
if ("1".equals(copyParam.getCopyJob())) {
|
||||||
List<JobPO> jobPOS = MapperProxyFactory.getProxy(JobMapper.class).listJobsByDepartmentId(id);
|
List<JobPO> jobPOS = MapperProxyFactory.getProxy(JobMapper.class).listJobsByDepartmentId(id);
|
||||||
for (JobPO jobPO : jobPOS) {
|
for (JobPO jobPO : jobPOS) {
|
||||||
// TODO 自动编号
|
try {
|
||||||
jobPO.setJobNo("部门复制_" + jobPO.getJobNo());
|
// 处理自动编号
|
||||||
|
jobPO.setJobNo(CodeRuleManager.getCodeRuleManager().generateRuleCode(RuleCodeType.
|
||||||
|
JOBTITLES, ""));
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
jobPO.setParentDept(deptById.getId());
|
jobPO.setParentDept(deptById.getId());
|
||||||
jobPO.setCreator((long) user.getUID());
|
jobPO.setCreator((long) user.getUID());
|
||||||
jobPO.setCreateTime(new Date());
|
jobPO.setCreateTime(new Date());
|
||||||
|
|
@ -645,29 +625,6 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取集团
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private SearchTree getTopGroup() {
|
|
||||||
RecordSet rs = new RecordSet();
|
|
||||||
String sql = "select * from HrmCompany ";
|
|
||||||
rs.executeQuery(sql);
|
|
||||||
SearchTree groupTree = new SearchTree();
|
|
||||||
groupTree.setCanClick(false);
|
|
||||||
groupTree.setCanceled(false);
|
|
||||||
groupTree.setCompanyid("1");
|
|
||||||
groupTree.setIcon("icon-coms-LargeArea");
|
|
||||||
groupTree.setId("0");
|
|
||||||
groupTree.setIsVirtual("0");
|
|
||||||
while (rs.next()) {
|
|
||||||
groupTree.setName(rs.getString("COMPANYNAME"));
|
|
||||||
}
|
|
||||||
groupTree.setSelected(false);
|
|
||||||
groupTree.setType(TYPE_GROUP);
|
|
||||||
return groupTree;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据keyword查询数据
|
* 根据keyword查询数据
|
||||||
|
|
@ -676,10 +633,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
||||||
* @param keyword
|
* @param keyword
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private List<TreeNode> getFilterCompany(String id, String keyword) {
|
private List<SearchTree> getFilterCompany(String id, String keyword) {
|
||||||
List<TreeNode> compSearchTree = new ArrayList<>();
|
|
||||||
|
|
||||||
//
|
|
||||||
// 查询部门信息
|
// 查询部门信息
|
||||||
Long parentCompId = StringUtil.isEmpty(id) ? null : Long.parseLong(id);
|
Long parentCompId = StringUtil.isEmpty(id) ? null : Long.parseLong(id);
|
||||||
CompPO compBuild = CompPO.builder().compName(keyword).parentCompany(parentCompId).build();
|
CompPO compBuild = CompPO.builder().compName(keyword).parentCompany(parentCompId).build();
|
||||||
|
|
@ -689,17 +643,8 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
||||||
for (CompPO compPO : filterComps) {
|
for (CompPO compPO : filterComps) {
|
||||||
buildParentComps(compPO, builderComps);
|
buildParentComps(compPO, builderComps);
|
||||||
}
|
}
|
||||||
List<SearchTree> compTrees = builderTreeMode(CompBO.buildSetToSearchTree(builderComps));
|
return SearchTreeUtil.builderTreeMode(CompBO.buildSetToSearchTree(builderComps));
|
||||||
|
|
||||||
// 排序,设置是否为叶子节点
|
|
||||||
List<TreeNode> collect = compTrees.stream().peek(item ->
|
|
||||||
item.setIsParent(CollectionUtils.isNotEmpty(item.getSubs()))
|
|
||||||
).sorted(Comparator.comparing(item -> Integer.parseInt(item.getId()))).collect(Collectors.toList());
|
|
||||||
if (CollectionUtils.isNotEmpty(collect)) {
|
|
||||||
compSearchTree.addAll(collect);
|
|
||||||
}
|
|
||||||
|
|
||||||
return compSearchTree;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -710,7 +655,7 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
||||||
*/
|
*/
|
||||||
private void buildParentComps(CompPO compPO, Set<CompPO> builderComps) {
|
private void buildParentComps(CompPO compPO, Set<CompPO> builderComps) {
|
||||||
builderComps.add(compPO);
|
builderComps.add(compPO);
|
||||||
if (isTop(compPO.getParentCompany())) {
|
if (SearchTreeUtil.isTop(compPO.getParentCompany())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CompPO parentComp = getCompMapper().listById(compPO.getParentCompany());
|
CompPO parentComp = getCompMapper().listById(compPO.getParentCompany());
|
||||||
|
|
@ -719,40 +664,5 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 处理树层级
|
|
||||||
*
|
|
||||||
* @param treeList
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private List<SearchTree> builderTreeMode(List<SearchTree> treeList) {
|
|
||||||
Map<String, List<TreeNode>> collects = treeList.stream().collect(Collectors.groupingBy(TreeNode::getPid));
|
|
||||||
return treeList.stream().peek(e -> e.setSubs(collects.get(e.getId()))).peek(item -> {
|
|
||||||
if (CollectionUtils.isNotEmpty(item.getSubs())) {
|
|
||||||
item.setIsParent(true);
|
|
||||||
}
|
|
||||||
}).filter(item -> isTop(item.getPid())).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断是为顶层数据
|
|
||||||
*
|
|
||||||
* @param pid
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private boolean isTop(Long pid) {
|
|
||||||
return null == pid;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断是为顶层数据
|
|
||||||
*
|
|
||||||
* @param pid
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private boolean isTop(String pid) {
|
|
||||||
return StringUtil.isEmpty(pid) || "0".equals(pid);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import com.api.browser.bean.BrowserBean;
|
||||||
import com.api.browser.bean.SearchConditionGroup;
|
import com.api.browser.bean.SearchConditionGroup;
|
||||||
import com.api.browser.bean.SearchConditionItem;
|
import com.api.browser.bean.SearchConditionItem;
|
||||||
import com.api.browser.bean.SearchConditionOption;
|
import com.api.browser.bean.SearchConditionOption;
|
||||||
import com.api.hrm.bean.TreeNode;
|
|
||||||
import com.cloudstore.eccom.pc.table.WeaTableColumn;
|
import com.cloudstore.eccom.pc.table.WeaTableColumn;
|
||||||
import com.cloudstore.eccom.result.WeaResultMsg;
|
import com.cloudstore.eccom.result.WeaResultMsg;
|
||||||
import com.engine.common.util.ServiceUtil;
|
import com.engine.common.util.ServiceUtil;
|
||||||
|
|
@ -49,8 +48,8 @@ import com.engine.organization.util.db.MapperProxyFactory;
|
||||||
import com.engine.organization.util.page.Column;
|
import com.engine.organization.util.page.Column;
|
||||||
import com.engine.organization.util.page.PageInfo;
|
import com.engine.organization.util.page.PageInfo;
|
||||||
import com.engine.organization.util.page.PageUtil;
|
import com.engine.organization.util.page.PageUtil;
|
||||||
|
import com.engine.organization.util.tree.SearchTreeUtil;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import weaver.conn.RecordSet;
|
|
||||||
import weaver.general.StringUtil;
|
import weaver.general.StringUtil;
|
||||||
import weaver.general.Util;
|
import weaver.general.Util;
|
||||||
import weaver.hrm.User;
|
import weaver.hrm.User;
|
||||||
|
|
@ -73,7 +72,6 @@ public class JobServiceImpl extends Service implements JobService {
|
||||||
* 1:分部
|
* 1:分部
|
||||||
* 2:部门
|
* 2:部门
|
||||||
*/
|
*/
|
||||||
private static final String TYPE_GROUP = "0";
|
|
||||||
private static final String TYPE_COMP = "1";
|
private static final String TYPE_COMP = "1";
|
||||||
private static final String TYPE_DEPT = "2";
|
private static final String TYPE_DEPT = "2";
|
||||||
|
|
||||||
|
|
@ -128,31 +126,11 @@ public class JobServiceImpl extends Service implements JobService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getSearchTree(SearchTreeParams params) {
|
public Map<String, Object> getSearchTree(SearchTreeParams params) {
|
||||||
Map<String, Object> dataMap = new HashMap<>();
|
|
||||||
SearchTree topGroup = getTopGroup();
|
|
||||||
// 集团
|
|
||||||
List<SearchTree> companyList = new ArrayList<>();
|
|
||||||
companyList.add(topGroup);
|
|
||||||
String keyword = params.getKeyword();
|
String keyword = params.getKeyword();
|
||||||
String type = Util.null2String(params.getType());
|
|
||||||
String id = params.getId();
|
String id = params.getId();
|
||||||
|
String type = Util.null2String(params.getType());
|
||||||
List<TreeNode> treeDatas = getFilterCompany(id, type, keyword);
|
List<SearchTree> treeList = getFilterCompany(id, type, keyword);
|
||||||
// 未点击,初始化树结构
|
return SearchTreeUtil.getSearchTree(type, treeList);
|
||||||
if (StringUtil.isEmpty(type)) {
|
|
||||||
dataMap.put("companys", companyList);
|
|
||||||
SearchTree rootCompany = getTopGroup();
|
|
||||||
rootCompany.setSubs(treeDatas);
|
|
||||||
rootCompany.setIsParent(CollectionUtils.isNotEmpty(rootCompany.getSubs()));
|
|
||||||
Map<String, Object> rootCompanyMap = new HashMap<>();
|
|
||||||
rootCompanyMap.put("rootCompany", rootCompany);
|
|
||||||
dataMap.put("datas", rootCompanyMap);
|
|
||||||
} else {
|
|
||||||
// 根据ID查询
|
|
||||||
dataMap.put("datas", treeDatas);
|
|
||||||
}
|
|
||||||
|
|
||||||
return dataMap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -444,8 +422,13 @@ public class JobServiceImpl extends Service implements JobService {
|
||||||
List<Long> idList = Arrays.stream(ids.split(",")).map(Long::parseLong).collect(Collectors.toList());
|
List<Long> idList = Arrays.stream(ids.split(",")).map(Long::parseLong).collect(Collectors.toList());
|
||||||
for (Long id : idList) {
|
for (Long id : idList) {
|
||||||
JobPO jobById = getJobMapper().getJobById(id);
|
JobPO jobById = getJobMapper().getJobById(id);
|
||||||
// TODO 自动编号
|
try {
|
||||||
jobById.setJobNo("复制_" + jobById.getJobNo());
|
// 处理自动编号
|
||||||
|
jobById.setJobNo(CodeRuleManager.getCodeRuleManager().generateRuleCode(RuleCodeType.
|
||||||
|
JOBTITLES, ""));
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
jobById.setParentDept(Long.parseLong(department));
|
jobById.setParentDept(Long.parseLong(department));
|
||||||
insertCount += getJobMapper().insertIgnoreNull(jobById);
|
insertCount += getJobMapper().insertIgnoreNull(jobById);
|
||||||
}
|
}
|
||||||
|
|
@ -485,7 +468,7 @@ public class JobServiceImpl extends Service implements JobService {
|
||||||
*/
|
*/
|
||||||
private void buildParentDepts(DepartmentPO departmentPO, Set<DepartmentPO> builderDeparts) {
|
private void buildParentDepts(DepartmentPO departmentPO, Set<DepartmentPO> builderDeparts) {
|
||||||
builderDeparts.add(departmentPO);
|
builderDeparts.add(departmentPO);
|
||||||
if (isTop(departmentPO.getParentDept())) {
|
if (SearchTreeUtil.isTop(departmentPO.getParentDept())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DepartmentPO parentDept = getDepartmentMapper().getDeptById(departmentPO.getParentDept());
|
DepartmentPO parentDept = getDepartmentMapper().getDeptById(departmentPO.getParentDept());
|
||||||
|
|
@ -502,7 +485,7 @@ public class JobServiceImpl extends Service implements JobService {
|
||||||
*/
|
*/
|
||||||
private void buildParentComps(CompPO compPO, Set<CompPO> builderComps) {
|
private void buildParentComps(CompPO compPO, Set<CompPO> builderComps) {
|
||||||
builderComps.add(compPO);
|
builderComps.add(compPO);
|
||||||
if (isTop(compPO.getParentCompany())) {
|
if (SearchTreeUtil.isTop(compPO.getParentCompany())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CompPO parentComp = getCompMapper().listById(compPO.getParentCompany());
|
CompPO parentComp = getCompMapper().listById(compPO.getParentCompany());
|
||||||
|
|
@ -511,30 +494,6 @@ public class JobServiceImpl extends Service implements JobService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取集团
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private SearchTree getTopGroup() {
|
|
||||||
RecordSet rs = new RecordSet();
|
|
||||||
String sql = "select * from HrmCompany ";
|
|
||||||
rs.executeQuery(sql);
|
|
||||||
SearchTree groupTree = new SearchTree();
|
|
||||||
groupTree.setCanClick(false);
|
|
||||||
groupTree.setCanceled(false);
|
|
||||||
groupTree.setCompanyid("1");
|
|
||||||
groupTree.setIcon("icon-coms-LargeArea");
|
|
||||||
groupTree.setId("0");
|
|
||||||
groupTree.setIsVirtual("0");
|
|
||||||
while (rs.next()) {
|
|
||||||
groupTree.setName(rs.getString("COMPANYNAME"));
|
|
||||||
}
|
|
||||||
groupTree.setSelected(false);
|
|
||||||
groupTree.setType(TYPE_GROUP);
|
|
||||||
return groupTree;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据keyword查询数据
|
* 根据keyword查询数据
|
||||||
*
|
*
|
||||||
|
|
@ -543,14 +502,14 @@ public class JobServiceImpl extends Service implements JobService {
|
||||||
* @param keyword
|
* @param keyword
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private List<TreeNode> getFilterCompany(String id, String type, String keyword) {
|
private List<SearchTree> getFilterCompany(String id, String type, String keyword) {
|
||||||
List<TreeNode> compSearchTree = new ArrayList<>();
|
List<SearchTree> searchTree = new ArrayList<>();
|
||||||
// 通过分部、公司 组装数据
|
// 通过分部、公司 组装数据
|
||||||
if (StringUtil.isEmpty(id) || TYPE_COMP.equals(type)) {
|
if (StringUtil.isEmpty(id) || TYPE_COMP.equals(type)) {
|
||||||
Long parentCompId = StringUtil.isEmpty(id) ? null : Long.parseLong(id);
|
Long parentCompId = StringUtil.isEmpty(id) ? null : Long.parseLong(id);
|
||||||
DepartmentPO departmentBuild = DepartmentPO.builder().deptName(keyword).parentComp(parentCompId).build();
|
DepartmentPO departmentBuild = DepartmentPO.builder().deptName(keyword).parentComp(parentCompId).build();
|
||||||
CompPO compBuild = CompPO.builder().compName(keyword).parentCompany(parentCompId).build();
|
CompPO compBuild = CompPO.builder().compName(keyword).parentCompany(parentCompId).build();
|
||||||
buildTreeByCompAndDept(departmentBuild, compBuild, compSearchTree);
|
searchTree = buildTreeByCompAndDept(departmentBuild, compBuild);
|
||||||
} else if (TYPE_DEPT.equals(type)) {
|
} else if (TYPE_DEPT.equals(type)) {
|
||||||
//
|
//
|
||||||
// 查询部门信息
|
// 查询部门信息
|
||||||
|
|
@ -559,16 +518,10 @@ public class JobServiceImpl extends Service implements JobService {
|
||||||
for (DepartmentPO departmentPO : filterDeparts) {
|
for (DepartmentPO departmentPO : filterDeparts) {
|
||||||
buildParentDepts(departmentPO, builderDeparts);
|
buildParentDepts(departmentPO, builderDeparts);
|
||||||
}
|
}
|
||||||
List<SearchTree> deptTrees = builderTreeMode(DepartmentBO.buildSetToSearchTree(builderDeparts));
|
searchTree = SearchTreeUtil.builderTreeMode(DepartmentBO.buildSetToSearchTree(builderDeparts));
|
||||||
// 排序,设置是否为叶子节点
|
|
||||||
List<TreeNode> collect = deptTrees.stream().peek(item ->
|
|
||||||
item.setIsParent(CollectionUtils.isNotEmpty(item.getSubs()))
|
|
||||||
).sorted(Comparator.comparing(item -> Integer.parseInt(item.getId()))).collect(Collectors.toList());
|
|
||||||
if (CollectionUtils.isNotEmpty(collect)) {
|
|
||||||
compSearchTree.addAll(collect);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return compSearchTree;
|
return searchTree;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -576,9 +529,9 @@ public class JobServiceImpl extends Service implements JobService {
|
||||||
*
|
*
|
||||||
* @param departmentBuild
|
* @param departmentBuild
|
||||||
* @param compBuild
|
* @param compBuild
|
||||||
* @param compSearchTree
|
* @return
|
||||||
*/
|
*/
|
||||||
private void buildTreeByCompAndDept(DepartmentPO departmentBuild, CompPO compBuild, List<TreeNode> compSearchTree) {
|
private List<SearchTree> buildTreeByCompAndDept(DepartmentPO departmentBuild, CompPO compBuild) {
|
||||||
List<DepartmentPO> filterDeparts = getDepartmentMapper().listByFilter(departmentBuild);
|
List<DepartmentPO> filterDeparts = getDepartmentMapper().listByFilter(departmentBuild);
|
||||||
// 查询分部信息
|
// 查询分部信息
|
||||||
List<CompPO> filterComps = getCompMapper().listByFilter(compBuild);
|
List<CompPO> filterComps = getCompMapper().listByFilter(compBuild);
|
||||||
|
|
@ -586,7 +539,7 @@ public class JobServiceImpl extends Service implements JobService {
|
||||||
for (DepartmentPO departmentPO : filterDeparts) {
|
for (DepartmentPO departmentPO : filterDeparts) {
|
||||||
buildParentDepts(departmentPO, builderDeparts);
|
buildParentDepts(departmentPO, builderDeparts);
|
||||||
}
|
}
|
||||||
List<SearchTree> deptTrees = builderTreeMode(DepartmentBO.buildSetToSearchTree(builderDeparts));
|
List<SearchTree> deptTrees = SearchTreeUtil.builderTreeMode(DepartmentBO.buildSetToSearchTree(builderDeparts));
|
||||||
// 添加部门的上级分部
|
// 添加部门的上级分部
|
||||||
String parentCompS = deptTrees.stream().map(SearchTree::getParentComp).collect(Collectors.joining(","));
|
String parentCompS = deptTrees.stream().map(SearchTree::getParentComp).collect(Collectors.joining(","));
|
||||||
if (!StringUtil.isEmpty(parentCompS)) {
|
if (!StringUtil.isEmpty(parentCompS)) {
|
||||||
|
|
@ -599,80 +552,9 @@ public class JobServiceImpl extends Service implements JobService {
|
||||||
for (CompPO compPO : filterComps) {
|
for (CompPO compPO : filterComps) {
|
||||||
buildParentComps(compPO, builderComps);
|
buildParentComps(compPO, builderComps);
|
||||||
}
|
}
|
||||||
List<TreeNode> compTrees = builderTreeMode(CompBO.buildSetToSearchTree(builderComps), deptTrees);
|
return SearchTreeUtil.builderTreeMode(CompBO.buildSetToSearchTree(builderComps), deptTrees);
|
||||||
|
|
||||||
// 排序,设置是否为叶子节点
|
|
||||||
List<TreeNode> collect = compTrees.stream().peek(item ->
|
|
||||||
item.setIsParent(CollectionUtils.isNotEmpty(item.getSubs()))
|
|
||||||
).sorted(Comparator.comparing(item -> Integer.parseInt(item.getId()))).collect(Collectors.toList());
|
|
||||||
if (CollectionUtils.isNotEmpty(collect)) {
|
|
||||||
compSearchTree.addAll(collect);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断是为顶层数据
|
|
||||||
*
|
|
||||||
* @param pid
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private boolean isTop(Long pid) {
|
|
||||||
return null == pid;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断是为顶层数据
|
|
||||||
*
|
|
||||||
* @param pid
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private boolean isTop(String pid) {
|
|
||||||
return StringUtil.isEmpty(pid) || "0".equals(pid);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 处理树层级
|
|
||||||
*
|
|
||||||
* @param treeList
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private List<SearchTree> builderTreeMode(List<SearchTree> treeList) {
|
|
||||||
Map<String, List<TreeNode>> collects = treeList.stream().collect(Collectors.groupingBy(TreeNode::getPid));
|
|
||||||
return treeList.stream().peek(e -> e.setSubs(collects.get(e.getId()))).peek(item -> {
|
|
||||||
if (CollectionUtils.isNotEmpty(item.getSubs())) {
|
|
||||||
item.setIsParent(true);
|
|
||||||
}
|
|
||||||
}).filter(item -> isTop(item.getPid())).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 组合分部、部门层级关系
|
|
||||||
*
|
|
||||||
* @param treeList
|
|
||||||
* @param deptTrees
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private List<TreeNode> builderTreeMode(List<SearchTree> treeList, List<SearchTree> deptTrees) {
|
|
||||||
Map<String, List<TreeNode>> parentMap = treeList.stream().collect(Collectors.groupingBy(TreeNode::getPid));
|
|
||||||
Map<String, List<SearchTree>> childMap = deptTrees.stream().collect(Collectors.groupingBy(SearchTree::getParentComp));
|
|
||||||
boolean isAdd = !childMap.isEmpty();
|
|
||||||
return treeList.stream().peek(e -> {
|
|
||||||
List<TreeNode> treeNodes = new ArrayList<>();
|
|
||||||
List<TreeNode> nodes = parentMap.get(e.getId());
|
|
||||||
if (CollectionUtils.isNotEmpty(nodes)) {
|
|
||||||
treeNodes.addAll(nodes);
|
|
||||||
}
|
|
||||||
if (isAdd && CollectionUtils.isNotEmpty(childMap.get(e.getId()))) {
|
|
||||||
treeNodes.addAll(childMap.get(e.getId()));
|
|
||||||
}
|
|
||||||
e.setSubs(treeNodes);
|
|
||||||
}).peek(item -> {
|
|
||||||
if (CollectionUtils.isNotEmpty(item.getSubs())) {
|
|
||||||
item.setIsParent(true);
|
|
||||||
}
|
|
||||||
}).filter(item -> isTop(item.getPid())).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否有搜索查询
|
* 是否有搜索查询
|
||||||
|
|
|
||||||
|
|
@ -113,5 +113,28 @@ public class MenuBtn {
|
||||||
return btnDatas;
|
return btnDatas;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取常用按钮列表
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Map<String, Object> getDatasNoBtnColum() {
|
||||||
|
Map<String, Object> btnDatas = new HashMap<>();
|
||||||
|
ArrayList<MenuBtn> topMenuList = new ArrayList<>();
|
||||||
|
ArrayList<MenuBtn> rightMenuList = new ArrayList<>();
|
||||||
|
// 新增
|
||||||
|
topMenuList.add(MenuBtn.topMenu_addNew());
|
||||||
|
// 批量删除
|
||||||
|
topMenuList.add(MenuBtn.topMenu_batchDelete());
|
||||||
|
btnDatas.put("topMenu", topMenuList);
|
||||||
|
// 新增
|
||||||
|
rightMenuList.add(MenuBtn.rightMenu_addNew());
|
||||||
|
// 日志
|
||||||
|
rightMenuList.add(MenuBtn.rightMenu_btnLog());
|
||||||
|
// 显示列定制
|
||||||
|
rightMenuList.add(MenuBtn.rightMenu_btnColumn());
|
||||||
|
btnDatas.put("rightMenu", rightMenuList);
|
||||||
|
return btnDatas;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,146 @@
|
||||||
|
package com.engine.organization.util.tree;
|
||||||
|
|
||||||
|
import com.api.hrm.bean.TreeNode;
|
||||||
|
import com.engine.organization.entity.searchtree.SearchTree;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
import weaver.general.StringUtil;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: TODO
|
||||||
|
* @author:dxfeng
|
||||||
|
* @createTime: 2022/06/06
|
||||||
|
* @version: 1.0
|
||||||
|
*/
|
||||||
|
public class SearchTreeUtil {
|
||||||
|
/**
|
||||||
|
* 左侧树 类型表示
|
||||||
|
* <p>
|
||||||
|
* 0:集团
|
||||||
|
* 1:分部
|
||||||
|
* 2:部门
|
||||||
|
*/
|
||||||
|
private static final String TYPE_GROUP = "0";
|
||||||
|
|
||||||
|
public static Map<String, Object> getSearchTree(String type, List<SearchTree> treeList) {
|
||||||
|
Map<String, Object> dataMap = new HashMap<>();
|
||||||
|
SearchTree topGroup = getTopGroup();
|
||||||
|
// 集团
|
||||||
|
List<SearchTree> companyList = new ArrayList<>();
|
||||||
|
companyList.add(topGroup);
|
||||||
|
|
||||||
|
List<TreeNode> treeDatas = new ArrayList<>();
|
||||||
|
// 排序,设置是否为叶子节点
|
||||||
|
List<TreeNode> collect = treeList.stream().peek(item ->
|
||||||
|
item.setIsParent(CollectionUtils.isNotEmpty(item.getSubs()))
|
||||||
|
).sorted(Comparator.comparing(item -> Integer.parseInt(item.getId()))).collect(Collectors.toList());
|
||||||
|
if (CollectionUtils.isNotEmpty(collect)) {
|
||||||
|
treeDatas.addAll(collect);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 未点击,初始化树结构
|
||||||
|
if (StringUtil.isEmpty(type)) {
|
||||||
|
dataMap.put("companys", companyList);
|
||||||
|
SearchTree rootCompany = getTopGroup();
|
||||||
|
rootCompany.setSubs(treeDatas);
|
||||||
|
rootCompany.setIsParent(CollectionUtils.isNotEmpty(rootCompany.getSubs()));
|
||||||
|
Map<String, Object> rootCompanyMap = new HashMap<>();
|
||||||
|
rootCompanyMap.put("rootCompany", rootCompany);
|
||||||
|
dataMap.put("datas", rootCompanyMap);
|
||||||
|
} else {
|
||||||
|
// 根据ID查询
|
||||||
|
dataMap.put("datas", treeDatas);
|
||||||
|
}
|
||||||
|
return dataMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取集团
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private static SearchTree getTopGroup() {
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
String sql = "select * from HrmCompany ";
|
||||||
|
rs.executeQuery(sql);
|
||||||
|
SearchTree groupTree = new SearchTree();
|
||||||
|
groupTree.setCanClick(false);
|
||||||
|
groupTree.setCanceled(false);
|
||||||
|
groupTree.setCompanyid("1");
|
||||||
|
groupTree.setIcon("icon-coms-LargeArea");
|
||||||
|
groupTree.setId("0");
|
||||||
|
groupTree.setIsVirtual("0");
|
||||||
|
while (rs.next()) {
|
||||||
|
groupTree.setName(rs.getString("COMPANYNAME"));
|
||||||
|
}
|
||||||
|
groupTree.setSelected(false);
|
||||||
|
groupTree.setType(TYPE_GROUP);
|
||||||
|
return groupTree;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理树层级
|
||||||
|
*
|
||||||
|
* @param treeList
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static List<SearchTree> builderTreeMode(List<SearchTree> treeList) {
|
||||||
|
Map<String, List<TreeNode>> collects = treeList.stream().collect(Collectors.groupingBy(TreeNode::getPid));
|
||||||
|
return treeList.stream().peek(e -> e.setSubs(collects.get(e.getId()))).peek(item -> {
|
||||||
|
if (CollectionUtils.isNotEmpty(item.getSubs())) {
|
||||||
|
item.setIsParent(true);
|
||||||
|
}
|
||||||
|
}).filter(item -> isTop(item.getPid())).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组合分部、部门层级关系
|
||||||
|
*
|
||||||
|
* @param treeList
|
||||||
|
* @param deptTrees
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static List<SearchTree> builderTreeMode(List<SearchTree> treeList, List<SearchTree> deptTrees) {
|
||||||
|
Map<String, List<TreeNode>> parentMap = treeList.stream().collect(Collectors.groupingBy(TreeNode::getPid));
|
||||||
|
Map<String, List<SearchTree>> childMap = deptTrees.stream().collect(Collectors.groupingBy(SearchTree::getParentComp));
|
||||||
|
boolean isAdd = !childMap.isEmpty();
|
||||||
|
return treeList.stream().peek(e -> {
|
||||||
|
List<TreeNode> treeNodes = new ArrayList<>();
|
||||||
|
List<TreeNode> nodes = parentMap.get(e.getId());
|
||||||
|
if (CollectionUtils.isNotEmpty(nodes)) {
|
||||||
|
treeNodes.addAll(nodes);
|
||||||
|
}
|
||||||
|
if (isAdd && CollectionUtils.isNotEmpty(childMap.get(e.getId()))) {
|
||||||
|
treeNodes.addAll(childMap.get(e.getId()));
|
||||||
|
}
|
||||||
|
e.setSubs(treeNodes);
|
||||||
|
}).peek(item -> {
|
||||||
|
if (CollectionUtils.isNotEmpty(item.getSubs())) {
|
||||||
|
item.setIsParent(true);
|
||||||
|
}
|
||||||
|
}).filter(item -> isTop(item.getPid())).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是为顶层数据
|
||||||
|
*
|
||||||
|
* @param pid
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private static boolean isTop(String pid) {
|
||||||
|
return StringUtil.isEmpty(pid) || "0".equals(pid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是为顶层数据
|
||||||
|
*
|
||||||
|
* @param pid
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean isTop(Long pid) {
|
||||||
|
return null == pid;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue