Browse Source

获取组织和网格树 网格加到组织里面 平级

dev_shibei_match
jianjun 4 years ago
parent
commit
b2f40e8ad9
  1. 5
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencyResultDTO.java
  2. 2
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencyTreeResultDTO.java
  3. 14
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java
  4. 9
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java
  5. 10
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java
  6. 58
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java
  7. 25
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml

5
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencyResultDTO.java

@ -41,9 +41,12 @@ public class AgencyResultDTO implements Serializable {
* 机关组织名称
*/
private String agencyName = "";
private String pid;
private String level;
/**
* 所有上级组织机构ID(以英文:隔开)
*/
@JsonIgnore
private String pids = "";
}
}

2
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencyTreeResultDTO.java

@ -24,6 +24,8 @@ public class AgencyTreeResultDTO implements Serializable {
private String agencyName;
private String pid;
private String level;
/**
* 下级机关组织
*/

14
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java

@ -325,7 +325,7 @@ public class CustomerAgencyController {
}
/**
* @Description 获取客户下组织树
* @Description 获取客户下组织树不含网格和部门
* @Param tokenDTO
* @Return {@link Result< AgencyTreeResultDTO >}
* @Author zhaoqifeng
@ -339,4 +339,16 @@ public class CustomerAgencyController {
return new Result<AgencyTreeResultDTO>().ok(customerAgencyService.getAgencyList(formDTO));
}
/**
* @Description 获取当前登陆人的 所属组织及下级组织/网格含直属网格
* @Param tokenDTO
* @Return {@link Result< AgencyTreeResultDTO >}
* @Author zhaoqifeng
* @Date 2021/9/8 15:20
*/
@PostMapping("agencygridtree")
public Result<AgencyTreeResultDTO> getOrgTreeData(@LoginUser TokenDto tokenDTO) {
return new Result<AgencyTreeResultDTO>().ok(customerAgencyService.getOrgTreeData(tokenDTO.getUserId()));
}
}

9
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java

@ -243,4 +243,11 @@ public interface CustomerAgencyDao extends BaseDao<CustomerAgencyEntity> {
AgencyTreeResultDTO getAllAgency(@Param("customerId") String customerId);
List<AgencyTreeResultDTO> getSubAgencyList(@Param("pid") String pid);
}
/**
* desc获取组织网格树 含直属网格
* @param agencyId
* @return
*/
AgencyTreeResultDTO getAgencyGridTree(String agencyId);
}

10
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java

@ -19,7 +19,6 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerAgencyDTO;
import com.epmet.dto.form.*;
@ -255,4 +254,11 @@ public interface CustomerAgencyService extends BaseService<CustomerAgencyEntity>
* @Date 2021/9/8 15:21
*/
AgencyTreeResultDTO getAgencyList(GetAgencyListFormDTO formDTO);
}
/**
* desc:获取用户所属组织的组织及网格树
* @param staffId
* @return
*/
AgencyTreeResultDTO getOrgTreeData(String staffId);
}

58
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java

@ -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

25
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml

@ -304,7 +304,9 @@
SELECT
ca.id AS "agencyId",
ca.organization_name AS "agencyName",
ca.pids AS "pids"
ca.pids AS "pids",
ca.PID AS pid,
ca.LEVEL
FROM
customer_agency ca
INNER JOIN customer_staff_agency csa ON ca.id = csa.agency_id
@ -507,6 +509,7 @@
<result column="agencyId" property="agencyId"/>
<result column="agencyName" property="agencyName"/>
<result column="pid" property="pid"/>
<result column="level" property="level"/>
</resultMap>
<resultMap id="NodeTreeResult" type="com.epmet.dto.result.AgencyTreeResultDTO"
extends="BaseResultMap">
@ -519,18 +522,32 @@
select
ID AS agencyId,
ORGANIZATION_NAME AS agencyName,
PID
PID,
LEVEL
from customer_agency
where
DEL_FLAG = 0
AND PID= #{pid}
ORDER BY ID
</select>
<select id="getSubGridList" resultMap="NodeTreeResult">
select
ID AS agencyId,
grid_name AS agencyName,
PID,
'grid' as LEVEL
from customer_grid
where
DEL_FLAG = 0
AND PID= #{pid}
ORDER BY ID
</select>
<select id="getAllAgency" resultMap="NodeTreeResult">
select
ID AS agencyId,
ORGANIZATION_NAME AS agencyName,
PID
PID,
LEVEL
from
customer_agency
where
@ -539,4 +556,4 @@
AND CUSTOMER_ID = #{customerId}
</select>
</mapper>
</mapper>

Loading…
Cancel
Save