|
|
@ -16,7 +16,6 @@ |
|
|
|
*/ |
|
|
|
|
|
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
@ -1107,6 +1106,63 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao |
|
|
|
return agency; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public AgencyTreeResultDTO getOrgTreeData(String staffId) { |
|
|
|
AgencyTreeResultDTO result = new AgencyTreeResultDTO(); |
|
|
|
//1.查询工作人员所属组织信息
|
|
|
|
AgencyResultDTO rootAgency = baseDao.selectAgencyByStaffId(staffId); |
|
|
|
if (null == rootAgency) { |
|
|
|
logger.error(String.format("查询工作人员所属组织信息失败,staffId->%s", staffId)); |
|
|
|
throw new RenException(CustomerAgencyConstant.SELECT_STAFF_AGENCY_EXCEPTION); |
|
|
|
} |
|
|
|
result.setPid(rootAgency.getPid()); |
|
|
|
result.setAgencyName(rootAgency.getAgencyName()); |
|
|
|
result.setAgencyId(rootAgency.getAgencyId()); |
|
|
|
result.setLevel(rootAgency.getLevel()); |
|
|
|
ExtStaffPermissionResultDTO res = baseDao.selectAgencyById(rootAgency.getAgencyId()); |
|
|
|
convert2AgencyTreeResult(result,res.getSubAgencyList(),res.getGridList()); |
|
|
|
return result; |
|
|
|
} |
|
|
|
/** |
|
|
|
* 递归查询子节点 |
|
|
|
* @param root 根节点 |
|
|
|
* @param all 所有节点 |
|
|
|
* @return 根节点信息 |
|
|
|
*/ |
|
|
|
private void convert2AgencyTreeResult(AgencyTreeResultDTO root, List<ExtStaffPermissionResultDTO> agencyList, List<ExtGridResultDTO> gridList) { |
|
|
|
try { |
|
|
|
for (ExtStaffPermissionResultDTO agency : agencyList) { |
|
|
|
AgencyTreeResultDTO resultDTO = new AgencyTreeResultDTO(); |
|
|
|
resultDTO.setAgencyId(agency.getAgencyId()); |
|
|
|
resultDTO.setAgencyName(agency.getAgencyName()); |
|
|
|
resultDTO.setPid(root.getAgencyId()); |
|
|
|
resultDTO.setLevel(agency.getLevel()); |
|
|
|
|
|
|
|
if (root.getSubAgencyList() == null) { |
|
|
|
root.setSubAgencyList(new ArrayList<>()); |
|
|
|
} |
|
|
|
root.getSubAgencyList().add(resultDTO); |
|
|
|
if (CollectionUtils.isNotEmpty(agency.getSubAgencyList()) || CollectionUtils.isNotEmpty(agency.getGridList())) { |
|
|
|
convert2AgencyTreeResult(resultDTO, agency.getSubAgencyList(), agency.getGridList()); |
|
|
|
} |
|
|
|
} |
|
|
|
for (ExtGridResultDTO o : gridList) { |
|
|
|
AgencyTreeResultDTO grid = new AgencyTreeResultDTO(); |
|
|
|
grid.setAgencyId(o.getGridId()); |
|
|
|
grid.setAgencyName(o.getGridName()); |
|
|
|
grid.setPid(root.getAgencyId()); |
|
|
|
grid.setLevel("grid"); |
|
|
|
grid.setSubAgencyList(null); |
|
|
|
if (root.getSubAgencyList() == null) { |
|
|
|
root.setSubAgencyList(new ArrayList<>()); |
|
|
|
} |
|
|
|
root.getSubAgencyList().add(grid); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 组织树最后一级没有数据的话设null |
|
|
|
* @Param agencyList |
|
|
|