|
|
|
@ -15,6 +15,7 @@ import com.zcloud.basic.info.dto.clientobject.DepartmentTreeInfoCO;
|
|
|
|
import com.zcloud.basic.info.persistence.dataobject.DepartmentDO;
|
|
|
|
import com.zcloud.basic.info.persistence.dataobject.DepartmentDO;
|
|
|
|
import com.zcloud.basic.info.persistence.repository.DepartmentRepository;
|
|
|
|
import com.zcloud.basic.info.persistence.repository.DepartmentRepository;
|
|
|
|
import com.zcloud.gbscommon.utils.PageQueryHelper;
|
|
|
|
import com.zcloud.gbscommon.utils.PageQueryHelper;
|
|
|
|
|
|
|
|
import com.zcloud.gbscommon.utils.Tools;
|
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
@ -50,37 +51,18 @@ public class DepartmentQueryExe {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<DepartmentTreeInfoCO> listTree(DepartmentTreeQry departmentQry) {
|
|
|
|
public List<DepartmentTreeInfoCO> listTree(DepartmentTreeQry departmentQry) {
|
|
|
|
if(Objects.isNull(departmentQry.getEqCorpinfoId())){
|
|
|
|
if (Objects.isNull(departmentQry.getEqCorpinfoId())) {
|
|
|
|
departmentQry.setEqCorpinfoId(AuthContext.getTenantId());
|
|
|
|
departmentQry.setEqCorpinfoId(AuthContext.getTenantId());
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Map<String, Object> parmas = PageQueryHelper.toHashMap(departmentQry);
|
|
|
|
Map<String, Object> parmas = PageQueryHelper.toHashMap(departmentQry);
|
|
|
|
List<DepartmentDO> pageResponse = departmentRepository.listTree(parmas);
|
|
|
|
List<DepartmentDO> pageResponse = departmentRepository.listTree(parmas);
|
|
|
|
if(CollUtil.isEmpty(pageResponse)) {
|
|
|
|
if (CollUtil.isEmpty(pageResponse)) {
|
|
|
|
return Collections.emptyList();
|
|
|
|
return Collections.emptyList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<DepartmentTreeInfoCO> examCenterCOS = departmentCoConvertor.converDOsToInfoCOs(pageResponse);
|
|
|
|
List<DepartmentTreeInfoCO> examCenterCOS = departmentCoConvertor.converDOsToInfoCOs(pageResponse);
|
|
|
|
Map<Long, List<DepartmentTreeInfoCO>> childrenMap = new HashMap<>();
|
|
|
|
return Tools.buildEntityTree(examCenterCOS, "id", "parentId", "childrenList");
|
|
|
|
for (DepartmentTreeInfoCO dept : examCenterCOS) {
|
|
|
|
|
|
|
|
childrenMap
|
|
|
|
|
|
|
|
.computeIfAbsent(dept.getParentId(), k -> new ArrayList<>())
|
|
|
|
|
|
|
|
.add(dept);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return buildTree(childrenMap, 0L);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private List<DepartmentTreeInfoCO> buildTree(Map<Long, List<DepartmentTreeInfoCO>> childrenMap, Long parentId) {
|
|
|
|
|
|
|
|
List<DepartmentTreeInfoCO> nodes = childrenMap.get(parentId);
|
|
|
|
|
|
|
|
if (nodes == null) {
|
|
|
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (DepartmentTreeInfoCO node : nodes) {
|
|
|
|
|
|
|
|
// 递归构建子节点
|
|
|
|
|
|
|
|
List<DepartmentTreeInfoCO> children = buildTree(childrenMap, node.getId());
|
|
|
|
|
|
|
|
node.setChildrenList(children);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return nodes;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public DepartmentCO info(Long id) {
|
|
|
|
public DepartmentCO info(Long id) {
|
|
|
|
DepartmentDO info = departmentRepository.getById(id);
|
|
|
|
DepartmentDO info = departmentRepository.getById(id);
|
|
|
|
|