日照智慧社区接口服务
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
3.1 KiB

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.stats.DimAgencyDao">
<select id="selectDimAgencyList" resultType="com.epmet.dto.stats.DimAgencyDTO">
SELECT
*
FROM
dim_agency
WHERE
del_flag = '0'
<if test="customerId != null and customerId.trim() != ''">
AND customerId = #{customerId}
</if>
</select>
5 years ago
<resultMap id="treeMap" type="com.epmet.dto.AgencySubTreeDto">
<id column="agencyId" property="agencyId" />
<result column="agencyName" property="agencyName"/>
<result column="customer_Id" property="customerId" />
<result column="PID" property="pid" />
<result column="LEVEL" property="level" />
<collection property="gridIds" ofType="java.lang.String">
<constructor>
<arg column="gridId"/>
</constructor>
</collection>
<collection property="subAgencies" column="agencyId"
ofType="com.epmet.dto.AgencySubTreeDto" select="selectSubAgencyByPid"></collection>
</resultMap>
<!-- 获取所有机关 递归入口 -->
<select id="selectAllAgency" resultMap="treeMap">
SELECT
agency.ID AS agencyId,
agency.ORGANIZATION_NAME AS agencyName,
grid.ID AS gridId,
agency.CUSTOMER_ID,
angency.PID,
agency.LEVEL
FROM
dim_agency agency
LEFT JOIN dim_grid grid ON agency.ID = grid.PID
AND grid.DEL_FLAG = '0'
WHERE
agency.DEL_FLAG = '0'
ORDER BY
agency.CUSTOMER_ID,
agency.PID
</select>
<!-- 根据PID获取下级机关 递归传递 -->
<select id="selectSubAgencyByPid" resultMap="treeMap" parameterType="string">
SELECT
agency.id AS agencyId,
agency.ORGANIZATION_NAME AS agencyName,-- agency.PID,agency.PIDS ,
grid.ID AS gridId, -- ,GRID_NAME
agency.CUSTOMER_ID,
agency.PID,
agency.LEVEL
FROM
dim_agency agency
LEFT JOIN dim_grid grid ON agency.ID = grid.PID
AND grid.DEL_FLAG = '0'
WHERE
agency.DEL_FLAG = '0'
AND agency.PID = #{pid}
ORDER BY
agency.CUSTOMER_ID,
agency.ID,
grid.ID
</select>
<!-- 获取顶级机关 递归入口 -->
<select id="selectTopAgency" resultMap="treeMap">
SELECT
agency.ID AS agencyId,
agency.ORGANIZATION_NAME AS agencyName,
grid.ID AS gridId,
agency.CUSTOMER_ID,
angency.PID,
agency.LEVEL
FROM
dim_agency agency
LEFT JOIN dim_grid grid ON agency.ID = grid.PID
AND grid.DEL_FLAG = '0'
WHERE
agency.DEL_FLAG = '0'
AND
agency.PID = '0'
ORDER BY
agency.CUSTOMER_ID,
agency.PID
</select>
</mapper>